站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题两种漂浮在页面中的广告代码

两种漂浮在页面中的广告代码

摘要: 两种漂浮在页面中的广告代码
<tr> <td>

  效果一:



<script language="javascript">

<textarea class=fm id=code1 rows=12 cols=78>

<script language="javascript"> var xPos = 20; var yPos = document.body.clientHeight; var step = 1; var delay = 10; var height = 0; var Hoffset = 0; var Woffset = 0; var yon = 0; var xon = 0; var pause = true; var interval; img.style.top = yPos; function changePos() { width = document.body.clientWidth; height = document.body.clientHeight; Hoffset = img.offsetHeight; Woffset = img.offsetWidth; img.style.left = xPos + document.body.scrollLeft; img.style.top = yPos + document.body.scrollTop; if (yon) { yPos = yPos + step; } else { yPos = yPos - step; } if (yPos < 0) { yon = 1; yPos = 0; } if (yPos >= (height - Hoffset)) { yon = 0; yPos = (height - Hoffset); } if (xon) { xPos = xPos + step; } else { xPos = xPos - step; } if (xPos < 0) { xon = 1; xPos = 0; } if (xPos >= (width - Woffset)) { xon = 0; xPos = (width - Woffset); } } function start() { img.visibility = "visible"; interval = setInterval('changePos()', delay); } start(); // End </script> </textarea>

<input style="CURSOR: hand" onfocus=this.blur() onclick="runEx('code5')" type=button value=运行代码> <input style="WIDTH: 95px; CURSOR: hand" onfocus=this.blur() onclick=cycode(code1) type=button value=复制到剪贴板 name=Submit> <input style="CURSOR: hand" onfocus=this.blur() onclick=svcode(code5) type=button value=另存代码> [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

  效果二:

<script>
var imagepath="/images/zp.gif"
var imagewidth=100 //这两行写图片的大小
var imageheight=100
var speed=2;
var imageclick=http://www.webjx.com //这里写点击图片连接到的地址
var hideafter=0
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.open(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 = '';
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>

<textarea class=fm id=code5 rows=12 cols=78><script> var imagepath="/images/logo.gif" var imagewidth=100 //这两行写图片的大小 var imageheight=100 var speed=2; var imageclick="http://www.webjx.com" //这里写点击图片连接到的地址 var hideafter=0 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.open(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 = ''; 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></textarea>

<input style="CURSOR: hand" onfocus=this.blur() onclick="runEx('code5')" type=button value=运行代码> <input style="WIDTH: 95px; CURSOR: hand" onfocus=this.blur() onclick=cycode(code5) type=button value=复制到剪贴板 name=Submit> <input style="CURSOR: hand" onfocus=this.blur() onclick=svcode(code5) type=button value=另存代码> [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
</td> </tr> </table>
↑返回目录
前一篇: 一种比较酷的页面载入特效代码
后一篇: 鼠标滑过超链接自动点击代码