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 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2002
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    simple document.write question

    Trying to make a page for kids to study definitions of words with a flash card style interface. I was using alert boxes to show the definition and out of curiosity changed alert to document.write.
    The results in IE6 were just great. Geko and IE 5 are lame.
    In IE6 when clicking on the word a whole new screen is written with the variable that is passed to "define".
    all others fail.

    I suspect that document.write was not meant to be used this way:

    Code:
    function test(define)
    {document.write ("<html><body><h2>",define ,"</h2><form>
    <input type='button' value='Back to Previous Page' onClick='javascript: history.go(1)'></form></body>
    </html>");
    }
    Code:
    <a href="" onClick="test(the definition of a word)">a word</a>
    I guess I'm wondering what is going on. Why in IE6 is all the HTML in the page being replaced with the HTML in the function?
    And why is it not working in other browsers.
    here's a sample IE6 only.

    Any insight about how to make this work in all browsers (without creating a new page for each definition or pop up windows) would be great.

    Thanks
    Pairustwo
    Last edited by pairustwo; 01-17-2003 at 11:45 PM.

  • #2
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you could use a <div id="sumthin"> & then use
    document.sumthin.innerHTML = "Somestuff" + define + "more stuff";

    Sorry, if im no help
    «Ðå G壣ꮻ²ºº²

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually that should be about right... you can't use document.write after the page has been displayed by the browser, you'd definitely need to edit the innerHTML...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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