Timbo87
asked on
What's wrong with this code? (history.previous)
Here's the objective of the code: If this page was accessed by a link, the errorurl is set to the page that accessed it (history.previous) if this page was accessed without a previous link, errorurl is set to the current URL.
errorurl = history.previous
if(errorurl==undefined) errorurl = window.location
Thanks
errorurl = history.previous
if(errorurl==undefined) errorurl = window.location
Thanks
ASKER
Thanks for the answer, but I don't want the browser page to change. I need to it to receive information. It's for a server error handler (404, 500, etc) and if they clicked a link and got a 404, I want it to report the page that they came from (history.previous). If they typed it in (no history) and got the error, I want it to display the page URL they typed in (window.location).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
** document.referrer.value **
ASKER
Thanks.
<html><head><title>test</t
<script langauge="JavaScript">
function GoPrevious() {
if (history.length != 0)
window.history.back();
else
window.location.reload();
}
</script>
</head>
<body>
<form name="theform">
<input type="button" value="Previous" onclick="javascript:GoPrev
</form>
</body></html>