How can I quote iframe's javascript variable in parent's window
In A.html I open an iframe with B.html in it.
in B.html,I write js:
<script type="javascript">
var b=0;
function test(){
alert(b);
return b;
}
</script>
so in A.html I want quote the variable b in B.html I write this:
<script type="javascript">
var a;
a=window.frames[0].b;
alert(a);
</script>
but the resault is "undefined"; however,I quote the function test in A.html
<开发者_运维知识库;script type="javascript">
var a;
a=window.frames[0]. test();
alert(a);
</script>
both the variable a and b could alert correctly
so why the second quote method could not work?
This works for me.
Which browser do you use? Are you sure that the document inside the frame is already loaded when you access the property?
精彩评论