I open a window with jQuery. Then I want to close it but window.close or nameOfTheWindow.close does not work. How should I do it?
I have the example here: 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();
});
})
window.open(), which allows you to access that "window's" object.