Results 1 to 5 of 5

Thread: Div position according to X

  1. #1
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default Div position according to X

    I have a div that needs to open according to the position of a link. The link appears on many pages at different position and the div MUST always open next to it.



    how do I do this????

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    How are you showing the div? It would be much easier to help you out if you could post a link to your site.

  3. #3
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default

    here is the code

    <html>
    <head>
    <title>Untitled</title>
    <script>
    function showd(element) {
    var el = document.getElementById(element);
    el.style.display = "block";
    }

    function closeContentD(element) {
    var el = document.getElementById(element);
    el.style.display = "none";
    }
    </script>

    <style>
    .div_watch_commentst_right{position:absolute;left:100px;top:100px;}
    </style>
    </head>
    <body>
    <a href="#" onClick="showd('myDivcom')" class="link">link1</a>
    <div id="myDivcom" style="display:none;border:1px solid red;width:350px;" class="div_watch_commentst_right">text comes here</div>
    <br>
    <a href="#" onClick="showd('myDivcom')" class="link">link2</a>
    </body>
    </html>

    I want the DIV to ALWAYS open close to its link

  4. #4
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    How about this:
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <script>
    function showd(element) {
    var el = document.getElementById(element);
    el.style.display = "inline";
    }
    function closeContentD(element) {
    var el = document.getElementById(element);
    el.style.display = "none";
    }
    </script>
    </head>
    <body>
    <a href="#" onClick="showd('myDivcom')" class="link">link1</a>
    <div id="myDivcom" style="display:none;border:1px solid red;width:350px;">text here</div>
    <br>
    <a href="#" onClick="closeContentD('myDivcom')" class="link">link2</a>
    </body>
    </html>
    Good luck!

  5. #5
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default

    not really.sorry
    forget about the close function.
    I want both my links to open the same div but the div will be positionned next to the relevant link

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
  •