Friday, December 12, 2008

Execute client side script in IFrame from parent page

To execute a script within in IFRAME from the parent page

Seems simple right? Sure it is... unless you want something that works in IE, Firefox, Chrome, and Safari. There are tons of blog posts, and articles on how to execute the script from the IFRAME on the parent, but surprisingly few articles on the opposite.

At the end of the day, this code should work in all 4 browsers:
function fnEvalFrame(iframe, command) {
if (!iframe.eval && iframe.execScript) {

Also, when referring to your frames, use self.frames (or self.frames[], window.frames[], top.frames[], parent.frames[]) and not document.frames

Firefox and document.frames
SSRS And Firefox
JavaScript eval in iframes

No comments: