SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting Layer's Top and Left

    Hi

    Friends i have a css style with the following parameters.

    #map{
    float: left;
    width: 451px;
    height: 307px;
    padding: 7px;
    }

    then i have a DIV with the ID of "map"

    now i want the browser to show me the TOp and LEFT parameters of the DIV when the page is shown in the browser.

    like i want to do like this :

    <script>
    var mapTop = document.getElementById( "map").style.top;
    var mapLeft = document.getElementById( "map").style.left;
    alert(mapTop);
    </script>

    but it a BLANK ALERT BOX

    plz help
    Last edited by zeeshanhashmi; Apr 5, 2007 at 08:05. Reason: correction

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can only access the CSS properties set in the style tag or set with JavaScript. To get the correct values set in the CSS file or any computed value you can use the following function.

  3. #3
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i do not want to know the CSS property. I want the POSITION of a LAYER on SCREEN.

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which is exactly what that function does... It will get the position or whatever property you want.


Bookmarks

Posting Permissions

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