技巧百问(5):打造超级浮动广告(不受屏幕限制)
放在/head和body之间,可以不受浏览器的限制全屏幕浮动
1 <script language="JavaScript">
2
3 var imagepath="/Images/Icon/ttqlogo.gif" //引用flash的话要注释掉这里
4 var imagewidth=128 //这两行写图片的大小
5 var imageheight=128
6 var speed=3;
7 var imageclick="/web3/qtt.jsp" //这里写点击图片连接到的地址
8 var hideafter=0
9 var isie=0;
10 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) {
11 isie=1;
12 }
13 else {
14 isie=0;
15 }
16 if(isie){ //引用flash的话要注释掉这里
17 var preloadit=new Image()
18 preloadit.src=imagepath
19 }
20 function pop() {
21 if(isie) {
22 x=x+dx;y=y+dy;
23 oPopup.show(x, y, imagewidth, imageheight);
24 if(x+imagewidth+5>screen.width) dx=-dx;
25 if(y+imageheight+5>screen.height) dy=-dy;
26 if(x<0) dx=-dx;
27 if(y<0) dy=-dy;
28 startani=setTimeout("pop();",50);
29 }
30 }
31 function dismisspopup(){
32 clearTimeout(startani)
33 oPopup.hide()
34 }
35 function dowhat(){
36 if (imageclick=="dismiss")
37 dismisspopup()
38 else
39 window.open(imageclick);
40 }
41 if(isie) {
42 var x=0,y=0,dx=speed,dy=speed;
43 var oPopup = window.createPopup();
44 var oPopupBody = oPopup.document.body;
45 oPopupBody.style.cursor="hand"
46 oPopupBody.innerHTML = '<IMG SRC="'+preloadit.src+'">'; //引用flash的话要注释掉这里
47 //-------------------引用flash-----------------------------
48 html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="300" height="180">';
49 html+='<param name="movie" value="地址">';
50 html+='<param name="quality" value="high">';
51 html+='<param name="wmode" value="transparent">';
52 html+='<embed src="地址" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="180"></embed>';
53 html+='</object>';
54 oPopupBody.innerHTML = html;
55 //--------------------------------------------------------
56 oPopup.document.body.onmouseover=new Function("clearTimeout(startani)")
57 oPopup.document.body.onmouseout=pop
58 oPopup.document.body.onclick=dowhat
59 pop();
60 if (hideafter>0)
61 setTimeout("dismisspopup()",hideafter*1000)
62 }
63 </script>
2
3 var imagepath="/Images/Icon/ttqlogo.gif" //引用flash的话要注释掉这里
4 var imagewidth=128 //这两行写图片的大小
5 var imageheight=128
6 var speed=3;
7 var imageclick="/web3/qtt.jsp" //这里写点击图片连接到的地址
8 var hideafter=0
9 var isie=0;
10 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) {
11 isie=1;
12 }
13 else {
14 isie=0;
15 }
16 if(isie){ //引用flash的话要注释掉这里
17 var preloadit=new Image()
18 preloadit.src=imagepath
19 }
20 function pop() {
21 if(isie) {
22 x=x+dx;y=y+dy;
23 oPopup.show(x, y, imagewidth, imageheight);
24 if(x+imagewidth+5>screen.width) dx=-dx;
25 if(y+imageheight+5>screen.height) dy=-dy;
26 if(x<0) dx=-dx;
27 if(y<0) dy=-dy;
28 startani=setTimeout("pop();",50);
29 }
30 }
31 function dismisspopup(){
32 clearTimeout(startani)
33 oPopup.hide()
34 }
35 function dowhat(){
36 if (imageclick=="dismiss")
37 dismisspopup()
38 else
39 window.open(imageclick);
40 }
41 if(isie) {
42 var x=0,y=0,dx=speed,dy=speed;
43 var oPopup = window.createPopup();
44 var oPopupBody = oPopup.document.body;
45 oPopupBody.style.cursor="hand"
46 oPopupBody.innerHTML = '<IMG SRC="'+preloadit.src+'">'; //引用flash的话要注释掉这里
47 //-------------------引用flash-----------------------------
48 html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="300" height="180">';
49 html+='<param name="movie" value="地址">';
50 html+='<param name="quality" value="high">';
51 html+='<param name="wmode" value="transparent">';
52 html+='<embed src="地址" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="180"></embed>';
53 html+='</object>';
54 oPopupBody.innerHTML = html;
55 //--------------------------------------------------------
56 oPopup.document.body.onmouseover=new Function("clearTimeout(startani)")
57 oPopup.document.body.onmouseout=pop
58 oPopup.document.body.onclick=dowhat
59 pop();
60 if (hideafter>0)
61 setTimeout("dismisspopup()",hideafter*1000)
62 }
63 </script>
现在引用的话背景我还无法弄透明,大家一起来研究