473,671 Members | 2,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I fix this dynamic menu ?

290 Contributor
Hi I have a dynamic menu on my site and it uses
javascript to make slide up and down the page.

I think its pretty cool but it seems that it works independently of the
page so if you try and reduce the width of the window, it starts getting messed up.

Have a look here and you will see what I mean:

my website

One other thing I don't like is that it forces the window to 100% each
time you click a link, I am sure that will annoy people.

Is there an easy way to stop the central column from "crashing into" the menu when the window width is reduced ?

And how do I stop this 100% window without messing the page up ?

Thanks for any advice.

The menu code is here :

(there are a few lines of php but the main part is all javascript)



Expand|Select|Wrap|Line Numbers
  1.  
  2. /*
  3. * Next display the menu.
  4. *
  5. *
  6. */
  7. $start = 0;
  8. $last = 20;
  9.  
  10.         $sql = "SELECT sc_name, user_id FROM clients
  11.         WHERE confirm = 'y'  
  12.       AND type = 'E'
  13.       ORDER BY lig_pos DESC LIMIT $start,$last";             
  14.  
  15.         $result = mysql_query($sql)
  16.          or die ("Could not execute STARTER FEATURE query.");
  17.  
  18.         while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
  19.             {
  20.             $Links[] = $row;
  21.             }
  22.  
  23.  
  24. //--> Output data.
  25.  
  26. echo '
  27. <div id="divStayTopLeft" style="position:absolute">
  28. <div class="menuH">Top Experts</div>
  29. <ul class="categorylinks">';
  30.  
  31. foreach ($Links as $Link){
  32. $the_link = str_replace(" ","%20",$Link['sc_name']);
  33. echo "<li><a href=\"/$the_link/internet_marketing/expert/guru_{$Link['user_id']}\">&nbsp;{$Link['sc_name']}</a></li>";
  34. }
  35. echo '</ul>';  
  36. ?>            
  37.  
  38. </div>
  39. <script type="text/javascript">
  40.  
  41.  
  42.  window.moveTo(0,0);
  43.  window.resizeTo(screen.width,screen.height);
  44.  
  45. /*
  46. Floating Menu script-  Roy Whittle (http://www.javascript-fx.com/)
  47. Script featured on/available at http://www.dynamicdrive.com/
  48. This notice must stay intact for use
  49. */
  50.  
  51. //Enter "frombottom" or "fromtop"
  52. var verticalpos="frombottom"
  53.  
  54. document.write('<\/div>')
  55.  
  56. function JSFX_FloatTopDiv()
  57. {
  58.     var startX = 20,
  59.     startY = 600;
  60.     var ns = (navigator.appName.indexOf("Netscape") != -1);
  61.     var d = document;
  62.     function ml(id)
  63.     {
  64.         var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
  65.         if(d.layers)el.style=el;
  66.         el.sP=function(x,y){this.style.left=x;this.style.top=y;};
  67.         el.x = startX;
  68.         if (verticalpos=="fromtop")
  69.         el.y = startY;
  70.         else{
  71.         el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
  72.         el.y -= startY;
  73.         }
  74.         return el;
  75.     }
  76.     window.stayTopLeft=function()
  77.     {
  78.         if (verticalpos=="fromtop"){
  79.         var pY = ns ? pageYOffset : document.body.scrollTop;
  80.         ftlObj.y += (pY + startY - ftlObj.y)/8;
  81.         }
  82.         else{
  83.         var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
  84.         ftlObj.y += (pY - startY - ftlObj.y)/8;
  85.         }
  86.         ftlObj.sP(ftlObj.x, ftlObj.y);
  87.         setTimeout("stayTopLeft()", 10);
  88.     }
  89.     ftlObj = ml("divStayTopLeft");
  90.     stayTopLeft();
  91. }
  92. JSFX_FloatTopDiv();
  93. </script>
  94.  
  95.  
Feb 2 '09 #1
1 1210
acoder
16,027 Recognized Expert Moderator MVP
The 100% problem is caused by lines 42-43. Remove them.

As for the script, it's a bit of mix-mash of old code/browser detection. You can use position: fixed instead. It works in most modern browsers. It doesn't work in IE6 though, but you can use this fix.
Feb 3 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2482
by: Macamba | last post by:
Hi all, I am currently developing a website for a voluntary organisation. It is my first step in website development. The dynamic menu I developed has some bugs, which I addressed in another post. In this post I want to ask you why my code behaves differently in IE, while it behaves like I expect in Mozilla and Opera. What I would like to see addressed is what I need to do to get the same behaviour in all 3 browsers. I know each browser...
4
5190
by: Stromboli | last post by:
hi people, My problem is that I need to build a dynamic menu (preferably that works in all the browsers) that appears when I mouseover a certain link. The problem is that I have to declare the menu content in the same part of the page where the menu goes (BODY). The content of the page is generated dynamically so I can't put the menu content it on the headers.
1
17659
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
1
1367
by: biela | last post by:
Hi I'm from Poland and I have small question :). I'm looking for sample example how to create dynamic menu. Generaly my website will see like that ------------------------------------ 2 ---------|--------------|----------- | | 1 | 3 | 4 | |
2
1755
by: vikram | last post by:
I have to design a page which contains a dynamic generated menu at left side.Menu will be generated once a user log in and will remain as it is for the rest of the user session. Problem is that due to client requirement i have to avoid using frames and hence menu and the page will be a single page. So is there is any way by which the left hande side menu block can be cached someway so that dynamic generation can be avoided each time...
19
258990
by: mart2006 | last post by:
I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters what is shown in the dynamic menu. For example, the first menu has three cities London, Paris, New York. If I choose London it populates the second menu with people from London. Here is the code I have for my dynamic menu <td valign=top><strong>Name:</strong></td> <td>...
3
4785
by: RahimAsif | last post by:
I am writing an application that requires the a portion of the main menu to be dynamic. The menu has file, panels, view files and help across the top. The view files sub menu needs to be dynamically generated, and the dynamic generation needs to occur right when the user selects this menu item (that is on the Popup event handler). However, everytime I put following code on the Popup event handler (of the View Files menuitem) to dynamically...
0
4535
by: benfly08 | last post by:
Hi, I used SWT to develop an windows application. In the application there is a dynamic created popup menu. The dynamic part is that i will pass a list of name to be a submenu of one menu item. However, when I code selection event, i cannot access to the list i pass in. Anybody got idea? Below is the code. public static void setUpMenu(final Shell shell, Menu popUpMenu, final String clientId) { myShell = shell; ...
10
57033
by: mart2006 | last post by:
Hi, I'm fairly new to PHP and I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters what is shown in the dynamic menu. For example, the first menu has three cities London, Paris, New York. If I choose London it populates the second menu with people from London. Here is the code I have for my dynamic menu <td...
0
8485
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.