window.frames[""].document.getElementById("")的问题
1.html
<HTML>
<BODY>
<iframe src= "s.html " name= "ii "> </iframe>
<script type= "text/javascript ">
alert(window.frames[ 'ii '].document.getElementById( "ss ").innerHTML);
</script>
</BODY>
</HTML>
s.html
<HTML>
<BODY>
<div id= "ss "> asdf </div>
</BODY>
</HTML>
报错~~请点拨
------解决方案-------------------- <script type= "text/javascript ">
function aa()
{
if(window.frames[ 'ii '].document.readyState != "complete ")
{
window.setTimeout(aa, 10)
}
else
{
alert(window.frames[ 'ii '].document.getElementById( "ss ").innerHTML);
}
}
aa()
</script>
------解决方案-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>
<BODY>
<iframe src= "Noname2.html " name= "ii "> </iframe>
</BODY>
<script type= "text/javascript ">
function func(){
alert(top.frames[ 'ii '].document.getElementById( "ss ").innerHTML);
}
</script>
<input type= "button " onclick= "func() ">
</HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>
<BODY>
<div id= "ss "> asdf </div>
</BODY>
</HTML>
直接打得时候他还没生成吧