對聯廣告在部分廣告站中是必須的,大多采用JS的方式,因為可關閉,而純CSS的js
下載:
對聯廣告.zip (其中需要廣告圖片路徑,請注意修改)
如上圖的代碼:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>對聯廣告</title> <script src="ad.js"></script> </head> <body> <style> /* a{position: fixed;top: 100px;}*/ </style> <script> function ad_left(){ var html; html = '<div id="ad_left" style="position:absolute; width:130px;height:300px;z-index:10001"><a style="position:absolute;top:-15px;left:0;" href="javascript:void(0);" onclick="document.getElementById(\'ad_left\').style.display=\'none\'">關閉</a><a href="http://www.jq-school.com"><img src="ad.jpg" width="130" height="300" /></a></div>'; dom.insertHtml(html);position.floatLeftCenter('ad_left'); } function ad_right(){ var html; html = '<div id="ad_right" style="position:absolute;width:130px;height:300px;z-index:10001"><a style="position:absolute;top:-15px;right:0;" href="javascript:void(0);" onclick="document.getElementById(\'ad_right\').style.display=\'none\'">關閉</a><a href="http://www.jq-school.com"><img src="ad.jpg" width="130" height="300" /></a></div>'; dom.insertHtml(html);position.floatRightCenter('ad_right'); } myEvent.add(window,'load',ad_left); myEvent.add(window,'load',ad_right); </script> </body> </html>