Question:
javascript - capturing domain change event OR domain of the target URL upon navigation to some other site?
srinath_sharoff
2009-06-03 21:47:21 UTC
Hi,

Is it possible to capture the domain change event OR domain of the target site in javascript? To elaborate, suppose I am on my site (www.mydomain.com) and if I type www.someotherdomain.com in the address bar, I want to capture the target URL/domain i.e. someotherdomain.com in the javascript code of my site (mydomain.com). Is there any way to achieve this? Pls advise.
I am trying to call sign-off function of my site upon customer navigation to some other site without loggin off. I can not use body/window onUnload function because I have a common layout JSP that would be reloaded for each and every page. So I am trying to capture the URL/domain of target site and check if it is different from teh current domain; Then only I will call my sign-off function to kill the customer session.
Three answers:
Robin T
2009-06-03 22:06:09 UTC
No you can't.



But there are a few alternatives:

1. Let the session expire automatically. After certain period of time (adjustable on the web server side) of inactivity on your website, the session will automatically expire.



2. Set the session to expire very quickly and create a request that reloads every a few seconds to reset the session timeout. This request can be a hidden iframe that reloads, or an Ajax request that sends a request, every a few seconds. The page being requested / reloaded should do nothing but extending the life of the session.
migoicons
2009-06-03 22:09:48 UTC
No, I never heard of a domain change event in JavaScript. Plus you can't close as server session with JavaScript that is the work of server side scripts, in your case (jsp). I am guessing you want to force the user to enter a password every time they to go your site whether they closed their browsers or not? If so you will have to configure your JSP code to timeout after a certain amount of time.
anonymous
2009-06-03 22:16:18 UTC
Get free ORACLE TUTORIAL and weight your CV/RERSUME for better jobs

http://itacumen.org/


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...