日期:2014-05-16  浏览次数:20383 次

请问在本地环境下主页面能否得到iframe里面b页面的input值吗?
代码如下:
HTML code
<html>  
<head>  
<title>Page A</title>  
<script>   
    var getValue=function(){   
        alert(window.frames['frame1'].document.getElementById('mytext').value);    
    }   
</script>  
</head>  
<body>  

    <iframe id="frame1" name="frame1" width="300" height="300"  src="http://127.0.0.1/b.html"></iframe> 
    <form method="post">
    <input type="text" id="mytext" value="I'm page A"/>
         <button onclick="getValue()">获取子窗口属性</button>  
    </form>
    
</body>  
</html>  



------解决方案--------------------
把src="http://127.0.0.1/b.html" 改成把src="b.html"