/    Sign up×
Community /Pin to ProfileBookmark

I want to load a page into a frame using javascript, and then run a function after that page has been loaded into the frame. I tried to do this with the following code:

[code]
window.frames[0].location.href=page;
window.frames[0].addEventListener(‘load’,myFunc,false);
[/code]

However, the event fires immediately (I assume because the frame has already loaded the original page it was displaying). Is there any way to accomplish what I am trying to do? Any help/info would be appreciated.

Thanks,
-Eddy999999

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@johns221bSep 08.2008 — one way is to do

<body onload="parent.myFunc()" > with in loaded page.

else using onreadystatechange
Copy linkTweet thisAlerts:
@Eddy999999authorSep 08.2008 — This is in a GreaseMonkey Script, so I don't have any control over the original contents of the page, and I'd rather not make it more complicated with AJAX if I don't have to...
Copy linkTweet thisAlerts:
@Eddy999999authorSep 09.2008 — Anyone have any ideas?
×

Success!

Help @Eddy999999 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,
)...