User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,641 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,195 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Nov 19th, 2005
Views: 5,471
Hi there is the code for floating some thing (menus image or what ever you want).You can set an specific location for the floating item and when you web page is scrolled down or up the object will float to that position slowly or fastly as you set them, just read the code completly and be sure to make ratings and coments
MAMIAOW
Rashid Mehmood
Last edited : May 25th, 2007.
javascript Syntax | 5 stars
  1. //MAMIAOW
  2. <html>
  3. <head>
  4. <Title>Floating Menu</title>
  5. </HEAD>
  6. <BODY background=bg.bmp>
  7.  
  8.  
  9.  
  10. <!-- Floating start -->
  11.  
  12.  
  13. <DIV id=divMenu
  14. style="VISIBILITY: visible; WIDTH: 10px; POSITION: absolute; TOP: 10px; HEIGHT: 10px">
  15.  
  16. <table><tr><td >
  17. INsert_your_Object Here_Here </td></tr></table></DIV>
  18. <SCRIPT>
  19.  
  20.  
  21. var isDOM = (document.getElementById ? true : false);
  22. var isIE4 = ((document.all && !isDOM) ? true : false);
  23. var isNS4 = (document.layers ? true : false);
  24. var isNS = navigator.appName == "Netscape";
  25.  
  26. function getRef(id) {
  27. if (isDOM) return document.getElementById(id);
  28. if (isIE4) return document.all[id];
  29. if (isNS4) return document.layers[id];
  30. }
  31.  
  32. function moveRightEdge() {
  33. var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck ;
  34.  
  35.  
  36. if (isNS4) {
  37. yMenuFrom = divMenu.top;
  38. yMenuTo = windows.pageYOffset + 137;
  39. } else if (isDOM) {
  40. yMenuFrom = parseInt (divMenu.style.top, 10);
  41. yMenuTo = (isNS ? window.pageYOffset : document.body.scrollTop) + 30; //Specify the distance of the Floating Object from top.
  42. }
  43. timeoutNextCheck = 50;
  44.  
  45. if (yMenuFrom != yMenuTo) {
  46. yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);//Specify the floating Speed high=0,slow=500. etc
  47. if (yMenuTo < yMenuFrom)
  48. yOffset = -yOffset;
  49. if (isNS4)
  50. divMenu.top += yOffset;
  51. else if (isDOM)
  52. divMenu.style.left = 120;//Specifies the distance of the floating object from left.
  53.  
  54. divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
  55. timeoutNextCheck = 0; //Specifies the speed of reaction .
  56. }
  57. setTimeout ("moveRightEdge()", timeoutNextCheck);
  58. }
  59.  
  60. if (isNS4) {
  61. var divMenu = document["divMenu"];
  62. divMenu.top = top.pageYOffset + 0;
  63. divMenu.visibility = "visible";
  64. moveRightEdge();
  65. } else if (isDOM) {
  66. var divMenu = getRef('divMenu');
  67. divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 0;
  68. divMenu.style.visibility = "visible";
  69. moveRightEdge();
  70. }
  71.  
  72. </SCRIPT>
  73. <!--floating end--!>
  74.  
  75. <br><br><br><br><br><br><br><br><br><br><br><br><br>Scroll down<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>v<br>dc
  76. </BODY>
  77. </HTML>
Comments (Newest First)
iamrashid | Newbie Poster | Aug 5th, 2006
Its Really Great:p
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 2:26 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC