Jul 24, 2008

Close Webpage If User Goes To Another Window

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

free web hosting

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?

 

 

 


Reply

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

 

 

 


Reply

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.

Reply

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

Reply

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

Reply

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.

Reply



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*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. close web page - 0.72 hr back. (1)
  2. direct to another webpage, html codes - 1.58 hr back. (1)
  3. disable message webpage your are viewing is trying to close the window - 2.29 hr back. (1)
  4. html close a page - 3.67 hr back. (1)
  5. how to close the self window in firefox through javascript - 7.02 hr back. (1)
  6. how to close webpage in firefox - 14.23 hr back. (2)
  7. the user is trying to close the webpage - 21.70 hr back. (1)
  8. close webpage - 23.36 hr back. (1)
  9. how to close window browser using title - 28.34 hr back. (1)
  10. code for closing explorer window using jsp - 34.47 hr back. (1)
  11. what is meant by browser window in html - 36.29 hr back. (1)
  12. ask confirmation on window close method - 37.71 hr back. (1)
  13. window.close avoid confirm message - 47.86 hr back. (1)
  14. javascript track if user goes to a different site - 51.60 hr back. (1)
Similar Topics

Keywords : close, webpage, user, window

  1. Button Animation With Rollover State That Stays When User Clicks A Button
    (0)
  2. Help With Java
    need to put applets or a webpage (3)
    hi, i'm a rather new java programmer and i was wondering if anyone knew how to put java applets
    onto a web page. please help me out. thank =) 1. Make your topic descriptions descriptive. They
    are important at trap17. 2. Moving to Java, javascripts, jsp ....

    1. Looking for close, webpage, user, window

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



Close Webpage If User Goes To Another Window



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE