Javascript實(shí)現(xiàn)帶關(guān)閉按鈕的網(wǎng)頁(yè)漂浮廣告代碼
更新時(shí)間:2014年01月12日 16:42:12 作者:
帶有關(guān)閉功能的漂浮圖片的實(shí)現(xiàn)方法有很多,下面為大家介紹下使用Javascript是如何實(shí)現(xiàn)的,喜歡的額朋友可以了解下
復(fù)制代碼 代碼如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>帶關(guān)閉按鈕的網(wǎng)頁(yè)漂浮廣告代碼</title>
</head>
<body>
<div id="img" style="position: absolute; left: 311; top: 815;visibility :hidden;" onmouseover="clearInterval(interval)" onmouseout="interval = setInterval('changePos()', delay)" align="right">
<a href="#" target="_blank"><img border="0" src="圖片路徑" onload="return imgzoom(this,600);" onclick="javascript:window.open(this.src);" style="cursor:pointer;"/></a>
<span style="CURSOR:hand;color:red;font-weight:bold" onclick="clearInterval(interval);img.style.visibility = 'hidden'">X</span>
</div>
<script language=javascript src=ff.js>
</script>
</body>
</html>
ff.js代碼
復(fù)制代碼 代碼如下:
var xPos = 20;
var yPos = document.body.clientHeight;
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;
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.style.visibility = "visible";
interval = setInterval('changePos()', delay);
}
start();
您可能感興趣的文章:
- JS實(shí)現(xiàn)關(guān)閉小廣告特效
- JS實(shí)現(xiàn)可關(guān)閉的對(duì)聯(lián)廣告效果代碼
- JS右下角廣告窗口代碼(可收縮、展開(kāi)及關(guān)閉)
- js實(shí)現(xiàn)網(wǎng)站最上邊可關(guān)閉的浮動(dòng)廣告條代碼
- JS實(shí)現(xiàn)可點(diǎn)擊展開(kāi)與關(guān)閉的左側(cè)廣告代碼
- JavaScript實(shí)現(xiàn)廣告的關(guān)閉與顯示效果實(shí)例
- js實(shí)現(xiàn)跟隨鼠標(biāo)移動(dòng)且?guī)шP(guān)閉功能的圖片廣告實(shí)例
- js退彈 IE關(guān)閉時(shí)彈出廣告代碼,可以防止屏蔽
- Javascript實(shí)現(xiàn)關(guān)閉廣告效果
相關(guān)文章
webpack學(xué)習(xí)--webpack經(jīng)典7分鐘入門(mén)教程
這篇文章主要介紹了webpack學(xué)習(xí)--webpack經(jīng)典7分鐘入門(mén)教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06
javascript文本框內(nèi)輸入文字倒計(jì)數(shù)的方法
這篇文章主要介紹了javascript文本框內(nèi)輸入文字倒計(jì)數(shù)的方法,涉及javascript針對(duì)鍵盤(pán)事件的操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-02-02
js判斷是否為數(shù)組的函數(shù): isArray()
像 Ajaxian,StackOverflow 等,搜一下,到處都在討論 isArray() 的實(shí)現(xiàn)。對(duì)于一切都是對(duì)象的 JavaScript 來(lái)說(shuō),確實(shí)有點(diǎn)麻煩2011-10-10
動(dòng)態(tài)統(tǒng)計(jì)當(dāng)前輸入內(nèi)容的字節(jié)、字符數(shù)的實(shí)例詳解
這篇文章主要介紹了動(dòng)態(tài)統(tǒng)計(jì)當(dāng)前輸入內(nèi)容的字節(jié)、字符數(shù)的實(shí)例詳解的相關(guān)資料,希望通過(guò)本文能幫助到大家,讓大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-10-10

