Getting Value From Popup Window Using only JS & HTML

守給你的承諾、 提交于 2019-12-02 06:56:50

It works for me (using Firefox 20.0). But the code is really ugly and old though, probably you should study the present standards of MSDN Window to understand how it works in firefox (Window object may change its behaviour in other browsers). Ah, and of course the ECMAScript . But to introuduce one of the multiple solutions, you could try this:
parent.html

<input type="text" id="output"/>
<button id="show">Open</button>

<script>
    document.getElementById('show').addEventListener('click', function(){
        window['output'] = document.getElementById('output');
        window.open('map.html')
    });
</script>  

maps.html (I changed the extension!)

<input type="text" id="user_text"/>
<input id="send" type='button' value'send'/>

<script>
    document.getElementById('send').addEventListener('click', function(){
    window.opener['output'].value = document.getElementById('user_text').value;
})
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!