Jump to content

parent.document.getElementById


harshpandya

Recommended Posts

EDIT: Ok, you figured it out. But what follows is a really great answer!The script thinks you are asking it to assign the return value of f() to parent.document.getElementById("start").onclick, so it runs the function right away to get the value for you. To assign the function itself (yeah, that sounds sloppy) to .onclick, you have 3 choices, each one just slightly different from what you tried.parent.document.getElementById("start").onclick = "f()";orparent.document.getElementById("start").onclick = f;or the somewhat fancier:parent.document.getElementById("start").onclick = function (){f();} ;The last is useful if you want to pass multiple parameters and execute multiple statements but for some reason don't want to create a public function. That might look like this:parent.document.getElementById("start").onclick = function (this, event){f(this.value); var a = check(event||window.event); if (a) {alert(this.message);}} ;Most folks use the first version. Real programmer types use the second. Idiots like me use the third.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...