Javascript 仅使用JS&;从弹出窗口获取值;HTML

Javascript 仅使用JS&;从弹出窗口获取值;HTML,javascript,popup,cross-page-postback,Javascript,Popup,Cross Page Postback,是否可以从弹出窗口中获取值?此外,我想只使用JS和HTML,即不使用PHP。这可能吗?我在这里看到过其他类似的帖子: 但这是在aspx中 我在谷歌上搜索了一下,发现了以下链接: 然而,它在那个家伙的网站上起作用,但当我复制并粘贴它时,它就不起作用了,我可能是一个noob,所以这就是我所拥有的: parent.html <html> <head> </head> <body> <form> <INPUT TYPE="TEXT"

是否可以从弹出窗口中获取值?此外,我想只使用JS和HTML,即不使用PHP。这可能吗?我在这里看到过其他类似的帖子:

但这是在aspx中

我在谷歌上搜索了一下,发现了以下链接:

然而,它在那个家伙的网站上起作用,但当我复制并粘贴它时,它就不起作用了,我可能是一个noob,所以这就是我所拥有的:

parent.html

<html>
<head>
</head>
<body>
<form>
<INPUT TYPE="TEXT" NAME="maparea" SIZE=2 VALUE="">
<input type=button onClick='targetitem = document.forms[0].maparea; dataitem = window.open("map.shtml", "dataitem", "toolbar=no,menubar=no,scrollbars=yes"); dataitem.targetitem = targetitem' value="Show Map">
</form>
</body>
</html>
<html>
<head>
<script>
function select_item(item)
{
targetitem.value=item;
top.close();
return false;
}
</script>
</head>

<body>

<CENTER>
<B>Our Map</B>
<BR>

<IMAGE SRC="map1.gif" ISMAP USEMAP="#MAP1">
<MAP NAME="MAP1">
<AREA SHAPE=RECT COORDS="11,10,116,133" HREF="" onClick='return select_item("1")'>
<AREA SHAPE=RECT COORDS="121,11,227,172" HREF="" onClick='return select_item("2")'>
<AREA SHAPE=RECT COORDS="11,140,115,226" HREF="" onClick='return select_item("3")'>
<AREA SHAPE=RECT COORDS="119,177,225,227" HREF="" onClick='return select_item("4")'>
<AREA SHAPE=default HREF="" >
</MAP>
</CENTER>
</body>
</html>

map.shtml

<html>
<head>
</head>
<body>
<form>
<INPUT TYPE="TEXT" NAME="maparea" SIZE=2 VALUE="">
<input type=button onClick='targetitem = document.forms[0].maparea; dataitem = window.open("map.shtml", "dataitem", "toolbar=no,menubar=no,scrollbars=yes"); dataitem.targetitem = targetitem' value="Show Map">
</form>
</body>
</html>
<html>
<head>
<script>
function select_item(item)
{
targetitem.value=item;
top.close();
return false;
}
</script>
</head>

<body>

<CENTER>
<B>Our Map</B>
<BR>

<IMAGE SRC="map1.gif" ISMAP USEMAP="#MAP1">
<MAP NAME="MAP1">
<AREA SHAPE=RECT COORDS="11,10,116,133" HREF="" onClick='return select_item("1")'>
<AREA SHAPE=RECT COORDS="121,11,227,172" HREF="" onClick='return select_item("2")'>
<AREA SHAPE=RECT COORDS="11,140,115,226" HREF="" onClick='return select_item("3")'>
<AREA SHAPE=RECT COORDS="119,177,225,227" HREF="" onClick='return select_item("4")'>
<AREA SHAPE=default HREF="" >
</MAP>
</CENTER>
</body>
</html>

功能选择项目(项目)
{
targetitem.value=项目;
top.close();
返回false;
}
我们的地图

任何帮助都将不胜感激。

它适合我(使用Firefox 20.0)。但是代码确实很难看而且很旧,也许你应该研究一下当前的标准来了解它在firefox中是如何工作的(Window对象可能会改变它在其他浏览器中的行为)。啊,当然还有。但要介绍多种解决方案中的一种,您可以尝试以下方法:
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>  

打开
document.getElementById('show').addEventListener('click',function(){
window['output']=document.getElementById('output');
window.open('map.html')
});
maps.html(我更改了扩展名!)


document.getElementById('send').addEventListener('click',function(){
window.opener['output'].value=document.getElementById('user_text').value;
})

我祈求好运。我要试试,让你知道。顺便说一句,我用的是chrome,刚刚试过。。。它不起作用了。。。也许这是铬的错。。。正在安装firefox。。。连接有点慢,所以我稍后会发回。我可以确认这在firefox中有效。但不是用铬!谢谢哈维尔给你的时间和努力。啊哈!:)最后,多亏了Javier和这个网站:检查第2页,如果html页面是通过文件访问的,那么window.opener将无法在chrome中工作:///我不知道为什么,但目前不关心,当我通过localhost访问该文件时。。。它可以按需要工作。。。