/    Sign up×
Community /Pin to ProfileBookmark

Error "window.onload is null or not an object" while setting the value.

HI
I am trying to create a link on a page which when clicked by the user would open a window and sign into it automatically. But when ever I try to edit the onload event on the child window through a button click on the parent window it gives me the error “window.onload is null or not an object” .Can’t it be done like this ?? if Yes then suggest any work around.

Thanks in Advance.

[SIZE=4]Code: –[/SIZE]
[U]To open the new window[/U]
[COLOR=DarkOliveGreen]var globalChildWin = window.open(“Some URL”);
addLoadEvent(“newOnLoad()”)[/COLOR]

[U]Function AddLoadEvent and newOnLoad: –[/U]

function addLoadEvent(func) {
var oldonload = globalChildWin.onload;
if (typeof window.onload != ‘function’) {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
function newOnLoad()
{
var doc = window.document;
var frm = doc.forms[0];
frm.Name.value = “Ali”
}

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @alijanjua spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...