///pc/img/blank.gif" width="12" height="8">当前位置:///default.htm" class="under">亿度网络 -> ///pc/index.htm" class="under">网页制作教程 -> JavaScript
///pc/homepage/javascript/sample/img/bule.gif" width="207" height="13"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/js.gif" width="186" height="20"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
    图形随窗口移动 ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
    ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  
效 果 演 示 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">

 

//www.shanghaigongsi.com.cn/pc/index.htm"> ///pc/homepage/javascript/sample/img/fix.gif" alt="你好,我总是在这!" border="0" >

拖动垂直滚动条,看看屏幕右下角的图形!
   
 
源代码如下 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">



这段程序放在<head>与</head>之间

这段程序放在<body ****>正文中

   
源程序讲解: ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
  ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  

function setVariables()
定义一个函数。
{ imgwidth=50;
imgheight=50;
设置两个变量的初值。
if (navigator.appName == "Netscape")
{ horz=".left";
vert=".top";
docStyle="document.";
styleDoc="";
innerW="window.innerWidth";
innerH="window.innerHeight";
offsetX="window.pageXOffset";
offsetY="window.pageYOffset"; }
如果浏览器是Netscape,设置各变量的值。
else { horz=".pixelLeft";
vert=".pixelTop";
docStyle="";
styleDoc=".style"; innerW="document.body.clientWidth";
innerH="document.body.clientHeight";
offsetX="document.body.scrollLeft"; offsetY="document.body.scrollTop"; }
如果浏览器是IE,设置各变量的值。
} function checkLocation() {
定义一个函数。
objectXY="branding";
var availableX=eval(innerW);
var availableY=eval(innerH);
var currentX=eval(offsetX);
var currentY=eval(offsetY);
声明变量,并赋值。
x=availableX-(imgwidth+30)+currentX;
y=availableY-(imgheight+20)+currentY;
evalMove();
设置图片的位置:离屏幕的右边为30,离屏幕下端为20。
setTimeout("checkLocation()",10); }
每10毫秒,调用一次checkLocation()函数。
function evalMove()
{ eval(docStyle + objectXY +
styleDoc + horz + "=" + x);}
eval(docStyle + objectXY +
styleDoc + vert + "=" + y); }
定义evalMove函数。
onload="setVariables(); checkLocation();" 页面装载时,调用setVariables(); checkLocation()函数。


  ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
 

 

网页制作 网页设计 网站建设 网站设计 网站制作 做网站 做网页