How can I grab a div from an iframe into a JS variable? Doesn't necessarily have to use jQuery.
+8
A:
document.getElementById('IframeId').contentWindow.document.getElementById('DivId');
Tracker1
2009-05-07 18:42:09
Excellent answer +1
Jose Basilio
2009-05-07 18:48:20
Just remember that this (or any other method) won't work cross domain because of security restrictions
Mike Robinson
2009-05-07 18:54:26
+9
A:
In jQuery syntax, that would be $('iframe').contents().find('div')
. (Substitute any specific ids/classes/other selectors you need, of course). Tracker1's answer should work fine for standard Javascript.
Greg Campbell
2009-05-07 18:49:16
I prefer the jQuery approach myself... bear in mind, it breaks when going more than one iFrame deep (like in MS's SQL Reporting services, ugh).
Tracker1
2010-03-08 23:40:53