Jump to content
xisto Community
Sign in to follow this  
p_a

Close Webpage If User Goes To Another Window

Recommended Posts

I have one html page, I replace it using Javascript to another, after checking if client browser is IE 6+ or not.

 

I have the html page, first.hml:

 

<HTML><HEAD><TITLE>MyFirstPage</TITLE></HEAD><script LANGUAGE="Javascript">if(window.navigator.appName == "Microsoft Internet Explorer" && window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE") + 5, window.navigator.appVersion.indexOf("MSIE") + 8) >= 6) window.location.replace("/second.html")elsewindow.location="/index_no_IE.html"</script><BODY></BODY></HTML>

If client uses IE 6+ he will get the second.html, not in new window, but in the same window, first.html will be replaced by second.html:

 

 

<HTML><HEAD><TITLE>MySecondPage</TITLE></HEAD><body onblur="self.close()"><B>This is The Second Page!</B></BODY></HTML>

I want the page to be closed if user goes to another window, or any other application, if user does switch to anything else.

 

Because of that, I did insert <body onblur="self.close()"> into the second.html

 

But I got the question:

 

The Web page you are viewing is trying to cloce the window.

Do you want to close this window?

 

Is there any possibility to avoid the question? To close the window without the question?

Share this post


Link to post
Share on other sites

NoNo...!

I guess you just wanted to direct visitors to a dedicated site meant to their browser specification. If this is true, the method you are doing issn't quite right.

It would still work, just require extra resources and memory since it's dealing with transitions between pages, opening and closing.

 

The proper method for browser detection can be easily found on the internet. They can detect browsers used by visitors and do to your request as programmed in the script.

 

Now this require javascript knowledge. If you didn't have some, probably you would need to post step-by-step request so the people in this community, javascript geeks i meant, can help you in no time.

 

Anyway, the browser detection scripts can be found at these sites:

http://www.quirksmode.org/js/detect.html

http://www.webreference.com/tools/browser/javascript.html

http://forums.xisto.com/no_longer_exists/

http://forums.xisto.com/no_longer_exists/

http://forums.xisto.com/no_longer_exists/

http://www.keynote.com/

http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

Thanks....Everything is okay with browser detection, it works very well, it's not the question.The question is at the end of the post. It's related to dialogbox which asks if Client wants the window to be closed. I want the window closed without the question.

Share this post


Link to post
Share on other sites

But I got the question:

 

The Web page you are viewing is trying to cloce the window.

Do you want to close this window?

 

Is there any possibility to avoid the question? To close the window without the question?

194807[/snapback]


Hello there! I'm guessing that your browser is Internet Explorer because it pops an confirm dialog box when you close it. If you're using different browsers like firefox, the window closes immediately and doesn't display a confirmation anymore. :)

Share this post


Link to post
Share on other sites

You can't avoid to display the confirmation message showed by the Internet Explorer browser. I don't think is a very useful method this java script you used. Check a popular site with these type of scripts.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.