• 各大网站都会在首页的上方两侧左右各挂一幅flash动画广告


    http://bbs.iwebhome.net/index.php?showtopic=2192
    你细心留意一下各大网站都会在首页的上方两侧左右各挂一幅flash动画广告,而该广告只是在用户的分辨率大于1024的情况下才显示,而在800的环境下是没有的,怎样实现呢?
    根据个人工作的总结把实现上面的功能代码写出来,以作备忘和方便有需要的朋友:

    lrbars.js

    var rightbar;
    var coupletcode;
    rightbar = window.screen.width-150+20 +5; //定义右侧广告的位置

    coupletcode = "<DIV id=leftbar style='LEFT: 5px; POSITION: absolute; TOP: 40px; VISIBILITY: hidden;' width=130>32</div> //显示左侧广告
    <DIV id=rightbar style='LEFT: " + rightbar + "px; POSITION: absolute; TOP: 40px; VISIBILITY: hidden' width=130>32</div>"; //显示右侧广告

    if (window.screen.width>=1024) //判断用户的屏幕分辨率是否大于或等于1024
    {
    document.write(coupletcode);
    }

    function InsertCouplet()
    {
    if (window.screen.width>=1024){ //如果用户屏幕分辩率大于或等于1024,则显示广告
    document.all.leftbar.style.visibility = "visible";
    document.all.rightbar.style.visibility = "visible";
    document.all.leftbar.innerHTML = "<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000

    codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 WIDTH=100 HEIGHT=300 id=leftB

    ALIGN=> <PARAM NAME=movie VALUE=top1.swf> <PARAM NAME=quality VALUE=high><PARAM NAME=wmode> <EMBED id=leftBG src=top1.swf

    quality=high WIDTH=100 HEIGHT=300 NAME=left ALIGN= TYPE=application/x-shockwave-flash

    PLUGINSPAGE=http://www.macromedia.com/go/getflashplayer></EMBED></OBJECT>";
    document.all.rightbar.innerHTML = "<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000

    codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 WIDTH=100 HEIGHT=300 id=rightB

    ALIGN=> <PARAM NAME=movie VALUE=top2.swf> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent><EMBED

    id=rightBG src=top2.swf quality=high WIDTH=100 HEIGHT=300 wmode=transparent NAME=right ALIGN=

    TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/go/getflashplayer></EMBED></OBJECT>";

    }
    }
    InsertCouplet();
    function leftBG_DoFSCommand(){ //关闭两侧广告

    document.all.leftbar.style.visibility = "hidden";
    document.all.rightbar.style.visibility = "hidden";

    }
    function rightBG_DoFSCommand(){
    leftBG_DoFSCommand();
    }
    <!--
    if (document.all){
    document.write("<script language=\"JavaScript\" For=\"rightB\" Event=\"FSCommand()\">\n");
    document.write(" leftBG_DoFSCommand();\n");
    document.write("</Script>\n");
    document.write("<script language=\"JavaScript\" For=\"leftB\" Event=\"FSCommand()\">\n");
    document.write(" rightBG_DoFSCommand();\n");
    document.write("</Script>\n");
    }
    //-->

    以上代码我是存在lrbars.js文件里,以方便其它页面调用

    之后在要显示广告的页里加入以下
    <script language="javascript" scr="lrbars.js"></script>
    ========================================
    在一个网站的首页两侧的对联式广告是怎么做的?
    请问是不是用层做的?

    答:都是用层做的,关闭广告就是把相应的层隐藏
    http://bbs.iwebhome.net/index.php?s=0dcc8008e7fe021afd2968b8eecb29aa&showtopic=2360&st=0&#entry4599
    <DIV id=leftbar style='LEFT: 5px; POSITION: absolute; TOP: 210px; VISIBILITY: visible;' width=130>
    <OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 WIDTH=100 HEIGHT=300 id=leftB ALIGN=> <PARAM NAME=movie VALUE=http://XXXX.swf> <PARAM NAME=quality VALUE=high><PARAM NAME=wmode> <EMBED id=leftBG src=http://XXXX.swf quality=high WIDTH=100 HEIGHT=300 NAME=left ALIGN= TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/go/getflashplayer></EMBED></OBJECT>
    </div>

    <DIV id=rightbar style='LEFT: 990px; POSITION: absolute; TOP: 210px; VISIBILITY: visible' width=130>
    <OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 WIDTH=100 HEIGHT=300 id=leftB ALIGN=> <PARAM NAME=movie VALUE=http://XXXXX.swf> <PARAM NAME=quality VALUE=high><PARAM NAME=wmode> <EMBED id=leftBG src=http://XXXXX.swf quality=high WIDTH=100 HEIGHT=300 NAME=left ALIGN= TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/go/getflashplayer></EMBED></OBJECT>
    </div>

    关闭按钮上直接用
    fscommand("quit");


  • 相关阅读:
    dedecms列表页实现文档按权重weight排序
    DEDEcms5.7各个文件的作用与安全防御设置
    我的SEO笔记
    分析网站日志
    网页上链接的添加规范与标准
    解决引用bootstrap样式时遇到的冲突问题
    js滚动到指定位置导航栏固定顶部
    使用rem自适应屏幕
    SQL 操作结果集 -并集、差集、交集、结果集排序
    简洁的左右滑动式轮播图
  • 原文地址:https://www.cnblogs.com/cy163/p/239055.html
Copyright © 2020-2023  润新知