views:

621

answers:

2

Does it have to open in the sam Eg:

function write(){ document.write("write") }

input type="button" onclick="write()" value="Click"

A: 

No, it doesn't always have to open in a new window.

Now, if you'll be a lot more specific I can give you a better answer.

Welbog
+6  A: 

document.write statements must be run before the page finishes loading

EDIT: Therefore, you wouldn't want to put document.write into an onclick

If you're trying to modify a page already loaded you'll have to use div tags and use something like:

document.getElementById("name").innerHTML = "bob";
McAden