prepareslideshow.js

来自「《JavaScript DOM编程艺术》一书中的配套源代码」· JavaScript 代码 · 共 29 行

JS
29
字号
function prepareSlideshow() {// Make sure the browser understands the DOM methods  if (!document.getElementsByTagName) return false;  if (!document.getElementById) return false;// Make sure the elements exist  if (!document.getElementById("linklist")) return false;  var slideshow = document.createElement("div");  slideshow.setAttribute("id","slideshow");  var preview = document.createElement("img");  preview.setAttribute("src","topics.gif");  preview.setAttribute("alt","building blocks of web design");  preview.setAttribute("id","preview");  slideshow.appendChild(preview);  var list = document.getElementById("linklist");  insertAfter(slideshow,list);// Get all the links in the list  var links = list.getElementsByTagName("a");// Attach the animation behavior to the mouseover event  links[0].onmouseover = function() {    moveElement("preview",-100,0,10);  }  links[1].onmouseover = function() {    moveElement("preview",-200,0,10);  }  links[2].onmouseover = function() {    moveElement("preview",-300,0,10);  }}addLoadEvent(prepareSlideshow);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?