jQuery: The Write Less, Do More JavaScript Library

Calling an iframe's javascript function

View: New views
2 Messages — Rating Filter:   Alert me  

Calling an iframe's javascript function

by Mike-735 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is there a way to implement this JavaScript commmand through JQuery?

document.getElementById('iframeid').contentWindow.myFunc();


Thanks!

Re: Calling an iframe's javascript function

by Michel Belleville :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well first you can find elements using their id :
$('#frameid')

Then access the content of an iframe :
$('#frameid').contents()

Then maybe access functions they own :
$('#frameid').contents().myFunc();

Though I don't know much about your "myFunc()" and how you attached it to the iframe, this should do the trick like your previous code.

Plus there's this nifty new web app that may help you with questions like this :
http://lmgtfy.com/?q=jquery+iframe

Check the first result...

Michel Belleville


2009/11/3 Mike <carr2424@...>
Is there a way to implement this JavaScript commmand through JQuery?

document.getElementById('iframeid').contentWindow.myFunc();


Thanks!