role
07-14-2003, 05:13 AM
hello, how to change onload event <body onload="do this"> to <body onload="do that"> using javascript?
|
Click to See Complete Forum and Search --> : change onload event using javascript? role 07-14-2003, 05:13 AM hello, how to change onload event <body onload="do this"> to <body onload="do that"> using javascript? Charles 07-14-2003, 05:36 AM <script type="text/javascript"> onload = function () {alert()} </script> role 07-15-2003, 12:24 AM not work in this script function changeMainPage(url) { parent.main_page.location = url; parent.main_page.onload = function() {alert('test')} } MadCommando 07-15-2003, 12:37 AM I don't think you could use "parent.main_page.onload" I think it would have to be in the page loaded, but I'm just taking a stab in the dark here. Charles 07-15-2003, 05:10 AM 1) You cannot set another page's "onload" handler before it loads. 2) If you set another page's "onload" handler after it loads then the handler will not be called. 3) JavaScript has as a security feature the limitation that y ou cannot mess with other people's documents. role 07-15-2003, 06:50 AM upss.. so there is no way i can get the script work :rolleyes: and why this script not work? <head> <script type="text/javascript"> <!-- onload = function() {do something} // --> </script> </head> <body onload="do something else"> i want first it "do something" and then "do something else" Charles 07-15-2003, 07:01 AM Originally posted by role why this script not work?For the same reason that given: foo = 'fee'; foo = 'fie'; foo equals 'fie' and not 'feefie'. Try onload = function () {doSomething(); doSomethingElse()} or <body onload="doSomething(); doSomethingElse()"> role 07-15-2003, 07:24 AM onload = function () {doSomething(); doSomethingElse()} it's work, but i want the <script> called doSomething() and the <body> tag called doSomethingElse() am i asked to much?? :p webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |