25 三 2007, 11:08下午
Uncategorized
by

发表点儿看法吧

滑动新闻栏~

信息量大了以后,版面是有限的~
横向满了,纵向来改进~
这种借鉴C/S系统中的滚动栏能很好的解决问题

moveElement.js

 

程序代码 程序代码

function moveElement(elementID,final_x,final_y,interval) {
if (!document.getElementById) return false;
if (!document.getElementById(elementID)) return false;
var elem = document.getElementById(elementID);
if (elem.movement) {
clearTimeout(elem.movement);
}
if (!elem.style.left) {
elem.style.left = “0px”;
}
if (!elem.style.top) {
elem.style.top = “0px”;
}
var xpos = parseInt(elem.style.left);
var ypos = parseInt(elem.style.top);
if (xpos == final_x && ypos == final_y) {
return true;
}
if (xpos < final_x) {
var dist = Math.ceil((final_x - xpos)/10);
xpos = xpos + dist;
}
if (xpos > final_x) {
var dist = Math.ceil((xpos - final_x)/10);
xpos = xpos - dist;
}
if (ypos < final_y) {
var dist = Math.ceil((final_y - ypos)/10);
ypos = ypos + dist;
}
if (ypos > final_y) {
var dist = Math.ceil((ypos - final_y)/10);
ypos = ypos - dist;
}
elem.style.left = xpos + “px”;
elem.style.top = ypos + “px”;
var repeat = “moveElement(‘”+elementID+“‘,”+final_x+“,”+final_y+“,”+interval+“)”;
elem.movement = setTimeout(repeat,interval);
}

prepareSlideshow.js

 

程序代码 程序代码

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);
[/color]

addLoadEvent.js

 

程序代码 程序代码

 

待完成~

*name

*e-mail

web site

给点儿指导意见:


 
  • 我在说

  • 我在看

  • 新文章

  • 文章归档