Wednesday, 18 December 2013

Back button code Javascript


Back button code Javascript

Today i will show you browser back button property. Most of people use browser back button for seeing previous page. Here i make back button using HTML and Javascript and people can put this button in a page. So visitors use that button to go for previous page.

Here you can use any HTML tag for click. I am using anchor tag here...

<a onclick="history.go(-1);"></a>

3 comments:

Unknown said...

If user click 2-3 time on same page -1 histroy will work Sir??/

Unknown said...

Sir If user click 2-3 time on same page will this (-)history will work as Expected???
Please upload Some tutorial on .net
Thanks a lot

PHP Coder said...

Good question saurabh.. After very deep thinking i have make below solution in PHP..

$ref = getenv("HTTP_REFERER");
session_start();
if($ref != ''){
$_SESSION['ref'] = $ref;
}
echo $_SESSION['ref'];