漂浮廣告是什麼?漂浮廣告如何設定

甲爪廣告聯盟發表於2019-02-16

在上一篇文章中甲爪聯盟有簡短的提到了漂浮廣告!漂浮廣告在廣告聯盟中網站主和目前網際網路網頁廣告運營的比較多,並且從效果來看漂浮廣告也是非常不錯的!但是個可能個別的站長對漂浮廣告瞭解不夠深,或者不知道怎麼設定漂浮廣告!所以甲爪聯盟就對漂浮廣告是什麼?漂浮廣告如何設定做出詳細的解答!

漂浮廣告( Floating Advertising)是指漂浮在網站首頁或各版塊、帖子等頁面的漂移形式的廣告。可以是圖片,可以是flash。首頁和各版塊帖子頁面都可以是獨立的廣告位。可以自動適應螢幕解析度,,不被任何網頁元素遮擋,同時可以支援多個圖片漂浮。漂浮式廣告就象永不消失的幽靈,在瀏覽網頁的時候,它會一直沿著設計好的路線漂移,設計路線不好的漂浮式廣告會分散網民的注意力,影響正常的瀏覽所以漂浮廣告在設定的時候也需根據實況來調整使用者體驗!

而漂浮廣告如何設定呢?其實網頁漂浮廣告,懸停廣告等廣告樣式在網上也有很多漂浮廣告實現程式碼程式碼!所以甲爪廣告聯盟就列舉三種漂浮廣告樣式!

第一種 漂浮廣告 不符合W3C
JavaScript漂浮廣告程式碼,很不錯,程式碼精簡,不過一次只有漂一個

<html> 
<head> 
<title>漂浮廣告</title> 
<body> 
<div id="codefans_net" style="position:absolute"> 
<!--連結地址--><a href="#" target="_blank"> 
<!--圖片地址--><img src="/images/logo.gif" border="0"> 
</a> 
</div> 
<script> 
var x = 50,y = 60 
var xin = true, yin = true 
var step = 1 
var delay = 10 
var obj=document.getElementById("codefans_net") 
function float() { 
var L=T=0 
var R= document.body.clientWidth-obj.offsetWidth 
var B = document.body.clientHeight-obj.offsetHeight 
obj.style.left = x + document.body.scrollLeft 
obj.style.top = y + document.body.scrollTop 
x = x + step*(xin?1:-1) 
if (x < L) { xin = true; x = L} 
if (x > R){ xin = false; x = R} 
y = y + step*(yin?1:-1) 
if (y < T) { yin = true; y = T } 
if (y > B) { yin = false; y = B } 
} 
var itl= setInterval("float()", delay) 
obj.onmouseover=function(){clearInterval(itl)} 
obj.onmouseout=function(){itl=setInterval("float()", delay)} 
</script> 
</body> 
</html> 

第二種 漂浮廣告 不符合標準
Js漂浮廣告程式碼,比較經典的浮動廣告,到現還很實用,比較適合站長,這種程式碼是必備的。

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>漂浮廣告</title> 
</head> 
<body> 
<DIV id=img1 style="Z-INDEX: 100; LEFT: 2px; WIDTH: 59px; POSITION: absolute; TOP: 43px; HEIGHT: 61px; 
visibility: visible;"><a href="http://www.jiazhua.com" target="_blank"><img src="/images/logo.gif" width="80" height="80" border="0"></a></DIV> 
<SCRIPT> 
var xPos = 300; 
var yPos = 200; 
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; 
img1.style.top = yPos; 
function changePos() 
{ 
width = document.body.clientWidth; 
height = document.body.clientHeight; 
Hoffset = img1.offsetHeight; 
Woffset = img1.offsetWidth; 
img1.style.left = xPos + document.body.scrollLeft; 
img1.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() 
{ 
img1.visibility = "visible"; 
interval = setInterval(`changePos()`, delay); 
} 
function pause_resume() 
{ 
if(pause) 
{ 
clearInterval(interval); 
pause = false;} 
else 
{ 
interval = setInterval(`changePos()`,delay); 
pause = true; 
} 
} 
start(); 
</SCRIPT> 
</body> 
</html> 

第三種 符合W3C的漂浮廣告程式碼

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>符合W3C的漂浮廣告程式碼-甲爪廣告聯盟</title> 
</head> 
<body> 
<script> 
document.write ("<DIV id=img1 style=`Z-INDEX: 100; LEFT: 2px; WIDTH: 252px; POSITION: absolute; TOP: 43px; HEIGHT: 172px; ") 
document.write (" visibility: visible;`> ") 
document.write (" <a href=`http://s.jb51.net` target=`_blank`> ") 
document.write (" <img src=`/upload/201204/20120411210123566.gif`style=border:none;/> ") 
document.write (" </a></DIV> ") 
var xPos = 300; 
var yPos = 200; 
var step = 1; 
var delay = 8; 
var height = 0; 
var Hoffset = 0; 
var Woffset = 0; 
var yon = 0; 
var xon = 0; 
var pause = true; 
var interval; 
img1.style.top = yPos; 
function changePos() 
{ 
width = document.documentElement.clientWidth; 
height = document.documentElement.clientHeight; 
Hoffset = img1.offsetHeight; 
Woffset = img1.offsetWidth; 
img1.style.left = xPos + document.documentElement.scrollLeft; 
img1.style.top = yPos + document.documentElement.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() 
{ 
img1.visibility = "visible"; 
interval = setInterval(`changePos()`, delay); 
} 
function pause_resume() 
{ 
if(pause) 
{ 
clearInterval(interval); 
pause = false;} 
else 
{ 
interval = setInterval(`changePos()`,delay); 
pause = true; 
} 
} 
start(); 
</script> 
</body> 
</html> 

Ps:以上程式碼如果在嘗試的時候!需要事先了解是否可行!

相關文章