Home > Web Front-end > JS Tutorial > javascript method to get the value of the element in the page in iframe_javascript skills

javascript method to get the value of the element in the page in iframe_javascript skills

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

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

Firefox method:
document.getElementById('myFrame').contentWindow.document.getElementById('test').value;

IE, Firefox method:

Copy code The code is as follows:

function getValue() {


var tmp = '';


if(document.frames){


tmp = 'Brother ie said:';


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


}else{


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


}


alert(tmp);


}


Sample code:
Code in a.html page
Copy code The code is as follows:


           
               
                <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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template