View Full Version : simple document.write question

01-17-2003, 11:43 PM
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:

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>

<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 (http://www.littlea.info/flashcard.htm) 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.


01-17-2003, 11:54 PM
I think you could use a <div id="sumthin"> & then use
document.sumthin.innerHTML = "Somestuff" + define + "more stuff";

Sorry, if im no help:rolleyes:

01-18-2003, 01:27 AM
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...