lost password?

home
•  xaraya
•  rails
•  django
•  webdev +
•  xamp
•  musings

rss
Tag this page
   

ยป Blogs that link here
last modified: Sep 21, 2006
(first posted: Aug 31, 2006)
(2099 Reads)
keywords: javascript
Permalink

Navigating with Javascript and Php

 

To go back to previous page (same as pressing the back button on your browser)

<a href="javascript:history.back()">Cancel</a>

To go back more than one page (e.g. 2 pages):

<a href="javascript:history.go(-2)">Return</a>

To close this window

<a href="javascript:window.close()">Close this window</a>

Both together:

    <xar:comment>Allow back if there's a place to go, else Close window</xar:comment>
<p>
<script language=javascript type="text/javascript">
<!--
if (history.length > 1) {
document.write( '<a href="javascript:history.back();"><xar:mlstring>or back to previous page</xar:mlstring></a>' );
} else {
document.write( '<a href="javascript:window.close()"><xar:mlstring>or close this window</xar:mlstring></a>' );
}
-->
</script>
</p>

If you want to go back, but need to refresh the page you came from, you can use this (in Xaraya template)

<a href="$_SERVER['HTTP_REFERER'']">Done</a>

 

 

There are no comments attached to this item.

Post a new comment

: This is not spam

Name :