首页 > 网站制作 > javascirpt 实现右侧浮动条

javascirpt 实现右侧浮动条

2008年8月22日 发表评论 阅读评论

javascirpt 实现右侧浮动条
浮动在右侧

  1. <!-- 告诉浏览器本网页符合XHTML1.0过渡型DOCTYPE -->
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
  3. <head>
  4. <title>网页设计师:关于我们</title>
  5. <!-- 定义语言编码 -->
  6. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  7. <meta http-equiv="Content-Language" content="gb2312" />
  8. <!-- 为搜索引擎准备的信息 -->
  9. <meta name="author" content="ajie@netease.com,阿捷" />
  10. <meta name="Copyright" content="www.w3cn.org,自由版权,任意转载" />
  11. <meta name="description" content="新网页设计师。web标准的教程站点,推动web标准在中国的应用" />
  12. <meta content="designing, with, web, standards, xhtml, css, graphic, design, layout, usability, accessibility, w3c, w3, w3cn, ajie,web标准" name="keywords" />
  13. <!-- 浏览器收藏夹小图标 -->
  14. <link rel="icon" href="/favicon.ico" type="image/x-icon" />
  15. <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  16. <!-- 双表法调用样式表 -->
  17.  
  18. </head>
  19. <body>
  20. <div style="height:2000px;">
  21. <div id=divMenu style="Z-INDEX: 1; right:1px; WIDTH: auto; POSITION: absolute; TOP: 84px; HEIGHT: auto; background-color:
  22. #330033; layer-background-color: #330033; border: 1px none #000000;"><A href="tencent://Message/?Uin=292842755"><IMG alt=点击这里给我发消息
  23. src="http://wpa.qq.com/pa?p=1:292842755:10" border=0></A></div>
  24.  
  25. <script language=JavaScript>
  26. var bNetscape4plus = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "4");
  27. var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");
  28. function CheckUIElements(){
  29.       var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;
  30.  
  31.       if ( bNetscape4plus ) {
  32.               yMenuFrom   = document&#91;"divMenu"&#93;.top;
  33.               yMenuTo     = top.pageYOffset + 295;
  34.       }
  35.       else if ( bExplorer4plus ) {
  36.               yMenuFrom   = parseInt (divMenu.style.top, 10);
  37.               yMenuTo     = document.body.scrollTop + 135; //距页面顶部的距离
  38.       }
  39.  
  40.       timeoutNextCheck = 500;
  41.  
  42.       if ( Math.abs (yButtonFrom - (yMenuTo + 152)) < 6 && yButtonTo < yButtonFrom ) {
  43.               setTimeout ("CheckUIElements()", timeoutNextCheck);
  44.               return;
  45.       }
  46.  
  47.       if ( yButtonFrom != yButtonTo ) {
  48.               yOffset = Math.ceil( Math.abs( yButtonTo - yButtonFrom ) / 10 );
  49.               if ( yButtonTo < yButtonFrom )
  50.                       yOffset = -yOffset;
  51.  
  52.               if ( bNetscape4plus )
  53.                       document&#91;"divLinkButton"&#93;.top += yOffset;
  54.               else if ( bExplorer4plus )
  55.                       divLinkButton.style.top = parseInt (divLinkButton.style.top, 10) + yOffset;
  56.  
  57.               timeoutNextCheck = 10;
  58.       }
  59.       if ( yMenuFrom != yMenuTo ) {
  60.               yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 20 );
  61.               if ( yMenuTo < yMenuFrom )
  62.                       yOffset = -yOffset;
  63.  
  64.               if ( bNetscape4plus )           
  65.                       document&#91;"divMenu"&#93;.top += yOffset;
  66.               else if ( bExplorer4plus )
  67.                       divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
  68.  
  69.               timeoutNextCheck = 10;
  70.       }
  71.  
  72.       setTimeout ("CheckUIElements()", timeoutNextCheck);
  73. }
  74. function OnLoad()
  75. {
  76.       var y;
  77.       if ( top.frames.length )
  78.       if ( bNetscape4plus ) {
  79.               document&#91;"divMenu"&#93;.top = top.pageYOffset + 135;
  80.               document&#91;"divMenu"&#93;.visibility = "visible";
  81.       }
  82.       else if ( bExplorer4plus ) {
  83.               divMenu.style.top = document.body.scrollTop + 235;
  84.               divMenu.style.visibility = "visible";
  85.       }
  86.       CheckUIElements();
  87.       return true;
  88. }
  89. OnLoad();
  90. </script>
  91. </div>
  92. </body>
  93. </html>
分类: 网站制作 标签:

  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.