Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Positioning this <div>

    hello there.

    I need a little help positioning a <div>. In its style I have its postition set to absolute and the top set to 60, but this div is the drop down bit of a drop down menu and the menu it is dropping down from is in the top right of the screen, so it is extremely hard to make it position to a certain amount from the right of the screen.

    The only method i could think of is to get the width of the screen, minus how far fom the right i want it, and apply this number to the "left" attribute of the div's style.

    This is the script i came up with to acheive this, but it doesnt work .


    Code:
    <script language="JavaScript">
    
    var winWidth;
    if (window.innerWidth) {
    winWidth=window.innerWidth; // for nn
    };
    else if (document.all) {
    winWidth=document.body.clientWidth; // for ie
    };
    var leftPos=winWidth-300; ////////// DISTANCE FROM LEFT////////
    if (document.layers) { 
      document.submenu.left=leftPos; // for nn4
    };
    if (document.all) {
      document.all.submenu.style.left=leftPos; // ie
    };
    if (document.getElementById) {
      document.getElementById("submenu").style.left=leftPos; //nn6
    };
    
    ////// Ignore this, its to make it appear and works fine ///////////
    function showMenu(show) {
    var visi;
    if (show) {visi="visible";}; 
    else {visi="hidden";}; 
    if (document.layers) { 
      document.submenu.visibility=visi;
      };
    if (document.all) {
      document.all.submenu.style.visibility=visi;
      };
    if (document.getElementById) {
      document.getElementById("submenu").style.visibility=visi;
      };
    };
    
    </script>


    any help would be greatly appreciated
    redhead

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    I thought for IE it was pixelLeft

    document.all.submenu.style.left=leftPos

    document.all.submenu.style.pixelleft=leftPos


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •