为啥世上会有这么多不同的浏览器?每次遇到js/css的浏览器兼容性问题,总是要发出这样的感叹,真希望这些个浏览器公司全部倒下,然后只留下一家(显然这是一个不可能实现的美好愿望),言归正传,看代码吧:
iframe框架内页:
<
html
>
< head >
< title > 框架内页 </ title >
</ head >
< body >
< div >
< input id ="txt1" name ="txt1" type ="text" value ="测试" />
</ div >
</ body >
</ html >
< head >
< title > 框架内页 </ title >
</ head >
< body >
< div >
< input id ="txt1" name ="txt1" type ="text" value ="测试" />
</ div >
</ body >
</ html >
父级类:
<
iframe
name
="frame1"
id
="frame1"
src
="frm.html"
frameborder
="1"
height
="30"
></
iframe
>
< p >
iframe1中文本框的值: </ p >
< p >
< input type ="button" name ="Submit" value ="getValue" onclick ="getValue()" />
</ p >
< script type ="text/javascript" >
function getValue(){
var ofrm1 = document.getElementById( " frame1 " ).document;
if (ofrm1 == undefined)
{
ofrm1 = document.getElementById( " frame1 " ).contentWindow.document;
var ff = ofrm1.getElementById( " txt1 " ).value;
alert( " firefox/chrome取值结果为: " + ff);
}
else
{
var ie = document.frames[ " frame1 " ].document.getElementById( " txt1 " ).value;
alert( " ie取值结果为: " + ie);
}
}
</ script >
< p >
iframe1中文本框的值: </ p >
< p >
< input type ="button" name ="Submit" value ="getValue" onclick ="getValue()" />
</ p >
< script type ="text/javascript" >
function getValue(){
var ofrm1 = document.getElementById( " frame1 " ).document;
if (ofrm1 == undefined)
{
ofrm1 = document.getElementById( " frame1 " ).contentWindow.document;
var ff = ofrm1.getElementById( " txt1 " ).value;
alert( " firefox/chrome取值结果为: " + ff);
}
else
{
var ie = document.frames[ " frame1 " ].document.getElementById( " txt1 " ).value;
alert( " ie取值结果为: " + ie);
}
}
</ script >