SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast lauriek's Avatar
    Join Date
    Dec 2002
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cross browser scripting question

    Hi,

    I have a script which needs to populate a html div with various things depenging on the paarameter supplied to the function. I have done this in the past with something like:-

    fullOpHtml = "<p>Blah blah</p>";
    document.all["outp"].innerHTML=fullOpHtml;

    which works with IE but I would also like this to work with Mozilla browsers.

    I have looked at using document.getElementById("outp") but I don't seem to be able to do a .innerHTML on that.

    This must be easy, whats the property/method I'm looking for? Preferably one method which would work for IE & MOzilla..

    Any pointers much appreciated as ever!

    Laurie

  2. #2
    SitePoint Enthusiast lauriek's Avatar
    Join Date
    Dec 2002
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just sussed this out...

    getelementbyid is the thing to use, however in Firefox, the DIV needs SOME content initially for this to work, and a "no-break-space" won't do it, it needs some actual text in there to start off with, otherwise Firefox just says "getelementbyid(thing) has no properties".

    If I give it just some default text content like so <div id=helpcontent>Help</div> then it all works fine assuming the div is above the script... Weird...

  3. #3
    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)
    Did you try giving the div "position:absolute" or "relative" ?
    Code:
    ...
    
    <style>
    #helpcontent {
      position:relative;
      overflow:hidden;
    }
    </style>
    
    ...
    
    <body>
    
    <div id='helpcontent'></div>
    
    ...


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
  •