jQuery로 창을 엽니 다. 그런 다음 닫고 싶지만 window.close 또는 nameOfTheWindow.close가 작동하지 않습니다. 어떻게해야합니까?
여기에 예제가 있습니다. http://jsfiddle.net/D99Gk/2/
HTML :
<a class="open" href="http://www.google.com" target="_blank"> open window 1 </a>
<br><br>
<a class="close" href="#"> close window 1</a>
JQUERY :
$(function(){
//I give the window the name window1 and I open it:
$('.open').click(function(e){
e.preventDefault();
window.open("","window1","width=400, height=400");
});
$('.close').click(function(){
// I tried and does not work:
// window.close();
// window1.close();
});
})
이렇게 :
$(function(){
var popup;
$('.open').click(function(e){
e.preventDefault();
popup = window.open("","window1","width=400, height=400");
});
$('.close').click(function(){
if(popup) popup.close();
});
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다