User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 332,632 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,257 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 913 | Replies: 5
Reply
Join Date: Sep 2007
Posts: 3
Reputation: balakumar1982 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
balakumar1982 balakumar1982 is offline Offline
Newbie Poster

Whether it is possible to find the response url in java script

  #1  
Sep 10th, 2007
I have a problem as following...
# I have stored some value in session to reach a Page "A"
# I have other pages "B", "C", "D".
# If I am moving from Page "A" to "B", I should not clear my session value but If I am moving from "A" to "C" or "A" to "D", then I have clear some values in session.
# I have clear it on body unload of "A" on condition. Is there any way to find the URL which I am landing via javascript? Is there any other way or work around to solve this problem.
Note: I have menu in my left frame and content in right frame. All my links to move from "A" to "B", "C" and "D" are in menu.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 901
Reputation: MattEvans will become famous soon enough MattEvans will become famous soon enough 
Rep Power: 4
Solved Threads: 43
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is online now Online
Posting Shark

Re: Whether it is possible to find the response url in java script

  #2  
Sep 10th, 2007
The URL of the document that the browser is currently viewing is in the property window.location.href
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Sep 2007
Posts: 3
Reputation: balakumar1982 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
balakumar1982 balakumar1982 is offline Offline
Newbie Poster

Re: Whether it is possible to find the response url in java script

  #3  
Sep 12th, 2007
Actually I wand to find which page I am going load from the current page. Whether It is possible to get that URL from a current page using javascript
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 901
Reputation: MattEvans will become famous soon enough MattEvans will become famous soon enough 
Rep Power: 4
Solved Threads: 43
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is online now Online
Posting Shark

Re: Whether it is possible to find the response url in java script

  #4  
Sep 12th, 2007
In Javascript, you cannot find where the user is going to go next, unless you strictly control the user's movement; something that you can only do within the realms of them navigating using your own controls.

i.e. it's not possible, unless it would suffice to only be notified of such an event if the user goes somewhere using a link directly on your page, in which case, it's easy; just add an onclick handler to all of the links to those other pages. You know where the link is going, because you wrote the link address. If you don't hardcode the link addresses for whatever reason, the link element's href property can be read, and obviously, you could do something more useful than this example with the address: ( i.e. check to see if it is an address for which your session needs to be cleared )
  1. <a href="http://somewhere.com" onclick="alert('Going to: ' + this.href);return true;">Going where?</a>
You cannot, ever, find out if a user is typing in a new URL and is about to hit enter, and browser forwards/backwards actions can't be reliably monitored, nor averted.

At the server, you can find out where the user has been going ( within your site ) by looking at where the user has come from ( REQUEST_URI in the HTTP header ). I don't believe that this is possible in Javascript.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Sep 2007
Posts: 3
Reputation: balakumar1982 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
balakumar1982 balakumar1982 is offline Offline
Newbie Poster

Re: Whether it is possible to find the response url in java script

  #5  
Sep 13th, 2007
Whether it is possible for me find the same in body unload event. i.e, document.getElementById("xx").href
where tag will look like this
<a href="http://somewhere.com" id="xx">Going where?</a>
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 901
Reputation: MattEvans will become famous soon enough MattEvans will become famous soon enough 
Rep Power: 4
Solved Threads: 43
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is online now Online
Posting Shark

Re: Whether it is possible to find the response url in java script

  #6  
Sep 13th, 2007
When the link has been clicked, put its' id ( or better, the object itself, or its href, or whatever ) in a global variable.
...
<script type="text/javascript">
var last_link = 0;
function unloading()
{
  if( last_link != 0 ){ ... }
}
function set_last_link( obj )
{
  last_link = obj;
}
</script>
</head>
<body onunload="unloading( );">
....
<a onclick="set_last_link( this ); return true;"/>
...

You might be better off using a javascript-controlled cookie all throughout the site; ie. on every page onload event, read the last URL from the cookie, do whatever you'd intend do when the previously loaded page was unloaded, then write the current URL to the cookie. That way, whenever the user moves between pages, you can find out where they came from. That's gotta be more useful, and flexible, and I can't think of any situation where that would be less suitable than trying to find out where the user is going.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 2:20 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC