您的位置:首页 > Web前端 > JavaScript

JS常用代码(10)

2013-04-11 19:26 288 查看
广告JS代码效果大全 ~~~~~~~~~~

4.[浮动对联广告---之左侧代码]

如果您想只有一侧显示的话,下面是实现左侧效果所需代码:

var ad_float_left_src ="图片地址";

var ad_float_left_url ="地址";

var ad_float_left_type = "";

document.ns = navigator.appName == "Microsoft Internet Explorer"

var imgheight_close

var imgleft

window.screen.width>800 ? imgheight_close=120:imgheight_close=120

window.screen.width>800 ? imgleft=8:imgleft=122

function myload()

{

myleft.style.top=document.body.scrollTop+document.body.offsetHeigh

t-imgheight_close;

myleft.style.left=imgleft;

leftmove();

}

function leftmove()

{

myleft.style.top=document.body.scrollTop+document.body.offsetHeigh

t-imgheight_close;

myleft.style.left=imgleft;

setTimeout("leftmove();",50)

}

function MM_reloadPage(init) { //reloads the window if Nav4

resized

if (init==true) with (navigator) {if ((appName=="Netscape")&&

(parseInt(appVersion)==4)) {

document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;

onresize=MM_reloadPage; }}

else if (innerWidth!=document.MM_pgW || innerHeight!

=document.MM_pgH) location.reload();

}

MM_reloadPage(true)

function close_float_left(){

myleft.style.visibility='hidden';

}

document.write("<div id=myleft style='position:

absolute;width:80;top:300;left:5;visibility: visible;z-index: 1'>"

+"<style>"

+"A.closefloat:link,A.refloat:visited {text-

decoration:none;color:#000000;font-size:12px}"

+"A.closefloat:active,A.refloat:hover {text-decoration:underline;color:#0000FF;font-size:12px}"

+"</style>"

+"<table border=0 cellpadding=0 cellspacing=0><tr><td>");

if(document.ns){

if(ad_float_left_type!="swf")

document.write("<a href='" + ad_float_left_url + "' target

= '_blank'><img src='" + ad_float_left_src + "' WIDTH=88

height=31 border=0></a>");

else

document.write("<EMBED src='" + ad_float_left_src + "'

quality=high WIDTH=80 HEIGHT=80 TYPE='application/x-shockwave-

flash' id=changhongout ></EMBED>");

document.write("</td></tr><tr><td width=80 height=20

align=right><a href='javascript:close_float_left( target=_blank);void(0);'

class=closefloat><b><font color=#ff0000>关闭</font></b></a></td></tr>"

+"</table>"

+"</div>");

myload()}

[ 5.背投广告]

<script language="javascript">

<!--

var sohu=window.open('http://www.sohu.com');

var ads=window.open('about:blank','ads','width=700,height=400');

sohu.focus();

ads.document.open();

ads.document.write ("<html><head><title>ads</title></head><body>This is background ads</body></html>");

ads.document.close();

//-->

</script>

[ 6.收缩广告]

<script language="javascript">

<!--

var bwidth=800;

var bheight=400;

function go() {

bwidth = bwidth - 10;

bheight = bheight - 5;

if(bwidth <= 10)

{ ads.style.display='none';clearTimeout("my"); }

else

{ ads.outerHTML='<span id="ads" style="width:'+bwidth+'px;height:'+bheight+'px;background-color:#0099FF;"></span>';}

var my=setTimeout("go()",50);

}

setTimeout("go()",6000);

//-->

</script>

<body topmargin="0" leftmargin="0">

<div align="center"><span id="ads" style="width:800px;height:400px;background-color:#0099FF"></span></div>

</body>

******************************************************************************

把上面的代码另存为三个*.JS文件,然后在想实现此效果的页面用

CODE:

<script src="*.js"></SCRIPT>

调用即可,*代表你另存的文件名!注意修改广告图片地址和连接地址!相应的参数可以根据页面自行调整

原文链接:http://www.cnblogs.com/koolay/articles/984852.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: