Nov 22, 2009

Close Webpage If User Goes To Another Window

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

Close Webpage If User Goes To Another Window

p_a
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:

CODE
<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")
else
window.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:


CODE
<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?

 

 

 


Comment/Reply (w/o sign-up)

Inspiron
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://webreference.com/tools/browser/javascript.html
http://www.mozilla.org/docs/web-developer/...owser_type.html
http://www.dithered.com/javascript/browser_detect/
http://www.sbrady.com/hotsource/javascript/brow.html
http://www.netmechanic.com/news/vol3/javascript_no15.htm
http://www.w3schools.com/js/js_browser.asp

 

 

 


Comment/Reply (w/o sign-up)

p_a
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.

Comment/Reply (w/o sign-up)

guangdian
i don't like this java code
sad.gif
i think it's unuseful for the webmaster and the custom

Comment/Reply (w/o sign-up)

leiaah
QUOTE
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?
*



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. smile.gif

Comment/Reply (w/o sign-up)

nelimitat
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.

Comment/Reply (w/o sign-up)

(G)Jim King
Close an IE tab programatically using javascript
Close Webpage If User Goes To Another Window

To close an IE tab programatically using javascript check out the following article :    http://www.Easykb.Com/default.Aspx?id=20

-reply by Jim King

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


Searching Video's for close, webpage, user, window
See Also,
advertisement


Close Webpage If User Goes To Another Window

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com