//////////////// the main page code
1 <html>
2 <head >
3 < title>MAIN</title >
4 < script type="text/_javascript_" >
5 // 主页面访问IFrame页面DOM内容
6 function oinit() {
7 alert(getIFrameDoc( "iframe1").getElementById(" idiv").id);
8 }
9 function getIFrameDoc(id) {
10 var iframe = document.getElementById(id);
11 var doc = (iframe.contentWindow || iframe.contentDocument );
12 if (doc.document) {
13 doc = doc.document;
14 }
15 return doc;
16 }
17 </script>
18 </head>
19 <body onload ="oinit()">
20 <div id ="odiv">
21 <iframe id ="iframe1" src ="iframe.html"></ iframe>
22 </div>
23 </body>
24 </html>
////////////// the iframe page code
1 <html>
2 <head >
3 < title>IFRAME</title >
4 < script type="text/_javascript_" >
5 // IFrame页面访问外层页面DOM内容
6 function iinit() {
7 alert(window.parent.document.getElementById( "odiv").id);
8 }
9 </script >
10 </ head>
11 <body onload="iinit() ">
12 <div id="idiv ">
13 </body>
14 </html>
On 8/25/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]
> wrote:
I have a scenario where I am trying to get to a div located within an
iframe from the parent using the jQuery $() selector. I have tried
multiple things but seem to have no luck. I was wondering if anyone
had some suggestions or some past issues with this.
Thanks in advance,
Jeff
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
--
刘远志
QQ:2065254
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/