页面中图片漂浮 Floating picⅢ 的制作


最新的图片漂浮脚本,这次的变化在于它不是单纯的在某个页面飘动,而是会垮页面飘动,也就是说你打开别的页面,它依然会存在,优先级是第一的,而且如果最小化所有窗口,它还会在桌面飘动,让你不胜其烦。

制作方法:
将下面的代码复制到<body>后:
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
//1) 指定图片的路径
var imagepath="LOGO.gif"

//2) 指定图片的大小尺寸
var imagewidth=88
var imageheight=31

//3) 调整速度 (lower is slower)
var speed=8;

//4) 设定点击图像时的行为
//"dismiss"值为解除图像的漂浮,当指定URL时,浏览器将链接该URL
var imageclick="dismiss"

//5) 最后,设定图像自动消失的时间,单位为秒(0=永久性)
var hideafter=0

////No editing required beyond this point/////////////////
var isie=0;
if(window.navigator.appName=="Microsoft Internet Explorer"&&window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE")+5,window.navigator.appVersion.indexOf("MSIE")+8)>=5.5) {
isie=1;
}
else {
isie=0;
}

if(isie){
var preloadit=new Image()
preloadit.src=../../imagepath
}

function pop() {
if(isie) {
x=x+dx;y=y+dy;
oPopup.show(x, y, imagewidth, imageheight);
if(x+imagewidth+5>screen.width) dx=-dx;
if(y+imageheight+5>screen.height) dy=-dy;
if(x<0) dx=-dx;
if(y<0) dy=-dy;
startani=setTimeout("pop();",50);
}
}

function dismisspopup(){
clearTimeout(startani)
oPopup.hide()
}

function dowhat(){
if (imageclick=="dismiss")
dismisspopup()
else
window.location=imageclick
}

if(isie) {
var x=0,y=0,dx=speed,dy=speed;
var oPopup = window.createPopup();
var oPopupBody = oPopup.document.body;
oPopupBody.style.cursor="hand"
oPopupBody.innerHTML = '<IMG SRC="'+preloadit.src+'">';
oPopup.document.body.onmouseover=new Function("clearTimeout(startani)")
oPopup.document.body.onmouseout=pop
oPopup.document.body.onclick=dowhat
pop();

if (hideafter>0)
setTimeout("dismisspopup()",hideafter*1000)
}
// -->
</SCRIPT>
注意代码中的描述文字,用户可相应改动代码!

至此你就可以完成这个实例了,快去试试吧!

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3