常用页面浮动广告代码

下面代码放在页头<HEAD><TITLE></TITLE>与</HEAD>之间:

<script language="JavaScript" type="text/JavaScript">

function mov(){

clearInterval(interval);

paust=false;

}

function out(){

document.getElementById("img").visibility = "visible"; 

interval = setInterval('changePos()', delay); 

paust=true;

}

</SCRIPT> 


下面代码放在页尾</BODY>与</HTML>之间:

<!--浮动-->

<div id="img" onMouseOver="mov()" onMouseOut="out()" style="position:absolute; z-index:2000; border-bottom-color:#0391B7;">

<div><img src="图片链接.jpg" onClick="window.open('跳转的网址链接')" width="180" height="104" style="border:1px solid #ddd;" /></div>

<div style="background-color:#0391B7;" align="center"><span class="white p12" style="CURSOR:hand;" onClick="document.getElementById('img').style.display = 'none';">关闭</span></div>

</div>

<!--浮动-->

<SCRIPT LANGUAGE="JavaScript"> 

<!-- 

var xPos = 20; 

var yPos = 0;

var step = 1; 

var delay = 30; 

var height = 0; 

var Hoffset = 0; 

var Woffset = 0; 

var yon = 0; 

var xon = 0; 

var pause = true; 

var interval; 

document.getElementById("img").style.top = yPos + "px"; 

function changePos() { 

width = document.body.clientWidth; 

height = document.body.clientHeight; 

Hoffset = document.getElementById("img").offsetHeight; 

Woffset = document.getElementById("img").offsetWidth; 

document.getElementById("img").style.left = xPos + document.body.scrollLeft + "px"; 

document.getElementById("img").style.top = yPos + document.body.scrollTop + "px"; 

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 www_helpor_net() { 

if(pause){

document.getElementById("img").visibility = "visible"; 

interval = setInterval('changePos()', delay); 

pause=true;

}else{

clearInterval(interval);

pause = false;}} 

www_helpor_net(); 

//For more,visit:www.helpor.net

--> 

</script>



评论

©阿諾|Powered by LOFTER