Web Analytics Made Easy -
StatCounter Positioning HV menu - CodingForum

Announcement

Collapse
No announcement yet.

Positioning HV menu

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Positioning HV menu

    I've recently put the HV menu into my site. The problem is that I can only position it from the .js file using 'start top' and 'start left'.
    I've also tried the relative positioning as mentioned in the config file. But I need to be able to position it either from my html code or my css style sheet.
    The reason I want to do this is because I've noticed that the menu does not sit correctly in my page when viewed on a monitor with a different resolution to the one I use when designing my web pages.
    PLEASE does anyone know if it's possible to position the menu in this way. Thanks, Kev

  • #2
    Once you know the correct values for each positioning variable for each resolution there are two alternatives.

    1/ (not recommended) on each page detect what the resolution is and link to a .js file with the correct positioning values in it
    i.e.
    PHP Code:
    <head>
    <
    script>
      var 
    menuFile="defaultMenuVars.js'
      var scrWidth=screen.width;
      if (scrWidth= 800) {menuFile="
    MenuVars800.js";}
      else
        {if (scrWidth=1024) {menuFile="
    MenuVars1024.js";}
           else
              etc etc   }
      document.write("
    <scr"+"ipt type='text/javascript' src="+menuFile+"></sc"+"ript>");
    </script>
    </head> 
    But that means making new variable files for each and every screen resolution and putting that code into each and every page.

    2/ In the variable declaration file detect the screen resolution in a similar manner and put the correct values for each resolution against startTop and StartLeft
    ie
    PHP Code:
    if (scrWidth=800) {startTop=32startLeft=45;}
    else
      {if (
    scrWidth=1024) {startTop=27startLeft=16;}
        else
          
    etc etc 
    This way you only have to alter on file.

    I hope that makes sense, I know how to do it but maybe not how to explain it.
    An answer needs a question just as much as a question needs an answer. Deep eh!

    Comment


    • #3
      Oky Doky. Just looked at the new thread you started. This is the answer to it.

      Im sure the code could be more elegant, I'll leave that up to somebody else, but this works.

      In the .js file that you have put all your menu options in there are a number of variables of which StartTop and StartLeft are two, these are the two that need to be altered to compensate for the resolution differences. First off you need to find out the correct position of the menu for each resolution by trial and error. Alter StartTop for the vertical position and StartLeft for the horizontal position in each resolution, make a note of the values when correct. Once you have these insert the following code into the .js file with your menu options in it below the StartTop and StratLeft variables.
      PHP Code:
      var adjT=0;
      var 
      adjL=0;
      var 
      scrWidth=screen.width;
      var 
      scrHeight=screen.height;

      if (
      scrWidth=1024&&scrHeight==768
          {
      StartTop=nn;
           
      StartLeft=nn;
           
      adjT=n;
           
      adjL=n;}
      else
      {if (
      scrWidth=800&&scrHeight==600
           {
      StartTop=nn;
            
      StartLeft=nn;
            
      adjT=n;
            
      adjL=n;}
       else
       {if (
      scrWidth=640&&scrHeight==480
           {
      StartTop=nn;
            
      StartLeft=nn;
            
      adjT=n;
            
      adjL=n;}
        else
        {if (
      scrWidth=1152&&scrHeight==864
            {
      StartTop=nn;
             
      StartLeft=nn;
             
      adjT=n;
             
      adjL=n;}
         else
         {if (
      scrWidth=1280&&scrHeight==1024
             {
      StartTop=nn;
              
      StartLeft=nn;
              
      adjT=n;
              
      adjL=n;}
          else
          {if (
      scrWidth=1600&&scrHeight==1200
              {
      StartTop=nn;
               
      StartLeft=nn;
               
      adjT=n;
               
      adjL=n;}
          }  
         }
        }
       }
      }

       if (
      navigator.appName=="Netscape")
        {
      StartTop=StartTop+adjT;
          
      StartLeft=StartLeft+adjL;
        { 
      I would suggest the initial value of StartTop and StartLeft should be the 800x600 resolution positions.

      Replace the 'nn' with the previously discovered values for each resolution.

      To complicate matters, if positioning is absolutley critical, Netscape and IE seem to require different values to place in the same spot. I have used the new variables adjT and adjL to adjust the StartTop and StartLeft. Replace the 'n' with the diffrence between the value for IE and the value for Netscape browsers to acheive the same position. If this is not a problem the just delete the code containing the variables.

      I hope all this makes sense, trying to erxplain it is worse than working it out. Good luck
      An answer needs a question just as much as a question needs an answer. Deep eh!

      Comment

      Working...
      X