IE Method:
Document.frames['myframe'mirror.doc ument. getElementById ('test'). value;
Firefox method:
Document.getelementbyid('myframe'{.content}doc ument. getElementById ('test'). value;
IE and Firefox methods:
Copy codeThe Code is as follows:
Function getValue (){
Var tmp = '';
If (document. frames ){
Tmp + = 'ie :';
Tmp + = document.frames{'myframe'}.doc ument. getElementById ('test'). value;
} Else {
Tmp = document.getelementbyid('myframe'{.content}doc ument. getElementById ('test'). value;
}
Alert (tmp );
}
Sample Code:
A.html Page code
Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title>
Javascript to obtain the value of elements in the iframe page
</Title>
</Head>
<Body>
<Iframe id = "myFrame" srcw.' B .html 'style = "width: 300px; height: 50px;"> </iframe>
<Input type = "button" id = "btn" onclick = "getValue ()" value = "test">
<Script type = "text/javascript">
Function getValue (){
Var tmp = '';
If (document. frames ){
Tmp + = 'ie :';
Tmp + = document.frames{'myframe'}.doc ument. getElementById ('test'). value;
} Else {
Tmp = document.getelementbyid('myframe'{.content}doc ument. getElementById ('test'). value;
}
Alert (tmp );
}
</Script>
</Body>
</Html>
B .html Page code
Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title>
I am a page in iframe
</Title>
</Head>
<Body>
<Input type = 'text' id = "test" value = 'Welcome to: justflyhigh.com '>
</Body>
</Html>