Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-05-16 16:59:511288browse

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>               
           
           
               
           
         
Statement:
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