Is it posible to use "confirmit" to open new url in the same window?
- by Dan Peschio
I'm using a the confirmit java script function to redirect to a new url with a positive response. It doesn't do exactly what I want - and maybe I can't have exactly what I want.
Here's what it does - onunload, with a positive response it opens the new url in a new window, which can be blocked by a pop-up blocker without the user even knowing, giving the impression that nothing happened. When it does open the new URL it opens in a new window making the desktop crowded. Its just not a great solution.
What I want it to do - onunload I'd like it to open the new url in the same window and have it not be classified as a "pop-up" to be blocked. I tried switching to onbeforeunload.... nuthin.
Is there a simple solution?
here's my current code:
<script language=javascript>
function confirmit()
{
var closeit= confirm("My message");
if (closeit == true)
{window.open("http://MyDestinationURL");}
else
{window.close();} } window.onunload = confirmit
</script>