PDA

View Full Version : JavaScritp & HTML


Aymen++
03-11-2003, 03:12 PM
when i click on the button that this code made it:

<HTML>
<HEAD></HEAD>
<BODY>
<FORM>
<script language= "JavaScript">
function printw(){
document.write("Aymen");
}
</SCRIPT>
<input type="button" value="ClickMe" onClick="printw()">
</FORM>
</BODY>
</HTML>

the button will disapear...
why?

beetle
03-11-2003, 03:34 PM
If you enact document.write() AFTER the document object has already loaded, a new document object will be created and put in place of the old. That is why you cannot use document.write() to place information into a page AFTER the BODY has fully loaded.

Aymen++
03-11-2003, 03:43 PM
is there any solution?

beetle
03-11-2003, 04:00 PM
Sure, you just need to know where you want to place the text, and if indeed it's just text. There's several ways to do this. Are you going to want to add/insert HTML? Or just text?

Aymen++
03-11-2003, 05:00 PM
i want to insert just a text