您现在的位置是:首页 > 电脑技术查询 > web开发

请教在本地环境下主页面能否得到iframe里面b页面的input值吗

编辑:chaxungu时间:2022-10-02 23:15:30分类:web开发

请问在本地环境下主页面能否得到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"