Posted in Javascript onFebruary 25, 2015
本文实例讲述了JS实现让网页背景图片斜向移动的方法。分享给大家供大家参考。具体实现方法如下:
<html> <head> <title>JS实现让网页背景图片斜向移动</title> <body background="images/changshi.ico"> <script language="Javascript"> <!-- function selectAll(theField){ var tempval=eval("document."+theField) tempval.focus() tempval.select() } //--> </script> <script language="Javascript"> <!-- var background = "images/changshi.ico"; var speed = 0; browserName = navigator.appName; browserVer = parseInt(navigator.appVersion); if (browserName != "Netscape" || browserVer >= 4.5) { function moveback(movert,movedn,hPos,vPos) { if (arguments[4]) document.body.style.backgroundImage = "url(\"" + arguments[4] + "\")"; if (arguments[5]) document.body.style.backgroundRepeat = arguments[5] if (!isNaN(hPos)) { if ((movert!=0) && (hPos>0)) hPos=-100000 hPos += movert } if (!isNaN(vPos)) { if ((movedn!=0) && (vPos>0)) vPos=-100000 vPos+= movedn } document.body.style.backgroundPosition= hPos + " " + vPos if (isNaN(hPos)) hPos = "\"" + hPos + "\"" if (isNaN(vPos)) vPos = "\"" + vPos + "\"" setTimeout("moveback("+movert+","+movedn+","+hPos+","+vPos+")",speed) } moveback(1,1,0,0, background); } //--> </script> </body> </html>
希望本文所述对大家的javascript程序设计有所帮助。
JS实现让网页背景图片斜向移动的方法
- Author -
代码家园声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@