javascript 获取iframe里页面中元素值的方法_javascript技巧

WBOY
Release: 2016-05-16 16:59:51
Original
1242 people have browsed it

IE方法:
document.frames['myFrame'].document.getElementById('test').value;

火狐方法:
document.getElementById('myFrame').contentWindow.document.getElementById('test').value;

IE、火狐方法:

复制代码代码如下:

function getValue(){


var tmp = '';


if(document.frames){


tmp += 'ie哥说:';


tmp += document.frames['myFrame'].document.getElementById('test').value;


}else{


tmp = document.getElementById('myFrame').contentWindow.document.getElementById('test').value;


}


alert(tmp);


}


示例代码:
a.html页面中的代码
复制代码代码如下:




<br> javascript 获取iframe里页面中元素的值 测试<br>








b.html页面中的代码
复制代码代码如下:




<br> 我是 iframe内的页面<br>





Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!