Closing A Window That Was Replaced
I need a way to make an 'Exit' button. I have a redirect page that opens a new window with JavaScript using _self, so it replaces the window. The next thing I need to do, is use
Solution 1:
Ok, someone told me that javascript could only close a window if that window remembered that it was opened by the javascript...or something like that.
Well, I might have discovered an exploit just now:
<divstyle="width: 128px; height: 32px; background-color:green;"onclick="doStuff()">Click me</div><script>functiondoStuff()
{
var myWindow = window.open("", "_self");
myWindow.document.write("This page will close in 3 seconds, for real...\<script\> setTimeout(function() { window.close(); }, 3000);\<\/script\>");
}
</script>
Did you see what I just did there, I sent a block of code to the newly opened page , and the new page ran it (at least on my chrome). So between the script tags, you could generate a button or something which closes the document (instead of the timeout function).
Post a Comment for "Closing A Window That Was Replaced"