Using JQuery to Access Iframe Content

Ajax, JQuery

Ran into an interesting problem today when trying to access iframe content using JQuery. I kept getting an uncaught exception error when trying access style attributes for content within the iframe.

JQuery makes accessing iframe content quite a simple process. Let’s say I have a div (id=’myBook’) in a file named thisbook.html.

<div id="myBook"></div>

In a parent file (index.html), we create an iframe:

To access the myBook div from the index.html page:

var book = $('#bookFrame').contents().find('#myBook');

Continue reading

Checkout My New Site - T-shirts For Geeks