I abandoned trying to do it in this scenario but I have been successful since with another implementation.
The only main thing I can see that I did different is that before I didn't have a src for the iframe. So I made a file and made sure I had all the starting tags. doctype, head etc, and I made the content be IE7 compatible.
Here is an example of what works for me.
- <script type="text/javascript">
- $(function(){
- var $divInIframe = $('#iframesId').contents().find('#divInIframe');
- });
- </script>
- <iframe id="iframesId" src="/includes/iframe_div.jsp" frameborder="0" width="215px" height="22px"></iframe>
This is the html src for the iframe:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="X-UA-Compatible" content="IE=7" />
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- </head>
- <body>
- <div id="divInIframe"></div>
- </body>
- </html>