Jquery 方式获取 iframe Dom元素
时间:2014-05-06 23:03:00
收藏:0
阅读:435
Jquery 方式获取 iframe Dom元素
测试页面代码:
<html> <head> <title>jquery方式,访问iframe页面dom元素</title> <meta name="Author" content="孙勤波"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <script type="text/javascript" src="http://s1.bdstatic.com/r/www/cache/static/jquery/jquery-1.10.2.min_f2fb5194.js"></script> <script type="text/javascript"> function getIframeDom(){ // 获取iframe的test元素 var test = $("#frame_1").contents().find("#test"); alert(test.html()) } </script> </head> <body> <iframe src="file:///C:/Users/SUN/AppData/Local/Temp/non9C34.htm" id="frame_1"></iframe> <br /> <a href="javascript:getIframeDom();">获取iframe 页面test元素内容</a> </body> </html>
<html> <head> <title>iframe页面a.html</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> </head> <body> <div id="test">我是测试页面test</div> </body> </html>
点击测试按钮效果:
评论(0)