SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Would like to make a script work with Mozilla

    I found this example of a script for finding the top and left edge of an element on a page, which is great. Their demo works fine in Mozi.

    http://1ppl.free.fr/html/article077.html

    I altered it so that it gets the top and left edges of a table instead of a div and then uses that information to position a div on the screen with a line like this:

    document.writeln('<div id="content8" style="left:' + (getAbsoluteLeft("mainTable") + 540) + 'px; top:' + (getAbsoluteTop("mainTable") + 315) + 'px;"><p class="homeTitles"><strong>A message from our chairman</strong></p><p class="homeCopy"><strong>Copy to follow.</strong></p></div>')

    See what I'm doing? This works fine in IE but not in Mozi? Is this because Mozi doesn't support getting the position of a table but does support it in divs, or is it something else? Is there any way to achieve this in Mozi? I've thought of a workaround involving nesting a div in a table and my table in that div, but it's a bit messy to say the least!

    Thanks in advance.

    G

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi greg,

    Is the page online? I was wondering if this code runs before window.onload - mainTable may not yet exist. Or is this script element in the html, after mainTable?

    The functions from 1ppl are fine. You shouldn't have to modify them. Are they in a script element before or after your code above?

  3. #3
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    It's not online at the moment. But the script elements are dealt with after mainTable is rendered. I came across that problem initially, but sussed out what was going on myself and put the script for displaying last. As I say, it works fine in IE and it kind of works in Mozi, but what it isn't doing is finding the left edge of the table accurately (I think).

    I'm not on a machine with Mozi today (hiding in a different office so I can actually get on with some work!!) -- it's an old PII Vaio and it's struggling enough without me giving it something else to worry about!

    G

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try letting the table have "position:relative" in css.

  5. #5
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm.... didn't work.

    Back on a Mozi machine now. What it's doing is it's measuring the top edge fine, but it's measuring from the left hand side of the screen rather than the left hand side of the table.


  6. #6
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Without seeing the page or at least some of the relevant code... I can only guess.

  7. #7
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    God, this is killing me! I even tried positioning a little div tag in the top left table cell and using that. Again, IE happy, Mozi not! And yet the demo works fine!!


  8. #8
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's ok. You were along the right lines. For some reason Mozi refuses to pick up the left edge of a table, even if you specify it's positioning in CSS. However, I added a little div with the ID of "marker" and when I set it's position to absolute Mozi would read it's left hand edge. I'm now using an empty div in the top left corner of the table instead of the table itself to keep Mozi happy.

    Thanks for your help Mike! I wouldn't have got there without you pointing me in the right direction!

    G

  9. #9
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're welcome, Greg. I'm glad you found a solution.


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
  •