2013-05-07 5 views
1

팝업 창에서 값을 가져올 수 있습니까? 또한 JS와 HTML 만 사용하고 싶습니다. 즉, PHP가 없습니다. 이것은 가능한가? 나는이 같은 여기에 다른 게시물을 본 적이 :팝업 창에서 값 가져 오기 JS 및 HTML 만 사용하기

getting value from popup window

하지만 영문으로있다.

내가 조금 인터넷 검색이 링크를 발견했다 그러나

http://www.bignosebird.com/js/popmap.shtml

을,이 녀석 사이트 있음에 작동하지만 내가 복사하고 붙여 넣을 때 이것이 내가 무엇 때문에, 나는 멍청한 놈 될 수 없습니다 이 :

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> 

map.s 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> 

모든 도움을 주시면 감사하겠습니다.

+0

오 얼마나 어리석은 I 였다. –

답변

2

나를 위해 (Firefox 20.0 사용) 작동합니다. 그러나 코드는 실제로 추악하고 오래되었습니다. 아마도 firefox에서 작동하는 방식을 이해하기 위해 MSDN Window의 현재 표준을 연구해야합니다 (Window 객체는 다른 브라우저에서 동작을 변경시킬 수 있음). 아, 물론 ECMAScript입니다. 그러나 여러 솔루션 중 하나를 introuduce, 당신이 시도 할 수 :
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 (나는 확장자를 변경!)

<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> 
+0

내 손가락이 엇갈립니다. 시도해보고 알게 해줘. BTW 나는 크롬을 사용하고 있습니다. –

+0

방금 ​​시도 ... 작동하지 않습니다 ... 아마도 이것은 크롬 오류입니다 ... 우리가 말하는 것처럼 파이어 폭스를 설치 중입니다 ... 연결이 조금 느려서 조금 나중에 다시 게시 할 것입니다. –

+0

파이어 폭스에서 작동하는지 확인할 수 있습니다. 그러나 크롬에 없다! 시간과 노력에 감사드립니다. –

관련 문제