...

View Full Version : need help with : history.go(var) where var is a value from a function



knightsjoker
12-02-2009, 04:59 PM
Hiya

was wondering if someone can help me with this:
basically i'm trying to create a Back button for a report page.

the first report page is a listing of dates... if i click on a date... it will open up a page with detail.

I want to put the history.go on the page with detail to go back to the date listing page.

obviously the page with details has page numbers. i already added a counter for clicking on the [previous] or [next].

i'm thinking of just using that click++ value and put the value on the var within history.go(var)




var clickCount = 1;

function addcount() {
a = clickCount++;
return a;
alert(a);
}

<a href="javascript:history.go( dunno what to put here )">Back</a>

<a href="abc" onclick="addcount()">Previous</a>
<a href="def" onclick="addcount()">Next</a>


possible?
or is there a better way to do this?
no direct url won't work.

Philip M
12-03-2009, 09:21 AM
I am not sure that I understand this, but I am not sure that you know how history.back() performs. It is the equivalent of the back button, and takes the user back to the previous URL entry in the browse navigation history list.

If you wish to direct the user to an URL you should use

window.location = "URL";



Have you seen our cat, Bert? Black with white paws, wearing collar with "Ernie" nametag. - Woking Review.

knightsjoker
12-03-2009, 10:09 AM
not allowed to use direct url otherwise i would have done so.

i've changed the code a bit...



<script language="Javascript">

var clickCount = 0;

function addcount() {
--clickCount;
return clickCount;
}

function glisting() {
num = addcount();
// alert(num);
window.history.go(num);
}

</script>


the code below is on the top of the detailed view of the report page


<a href="javascript:glisting()">Back to listing</a>


the code below is the pagination on the detailed view of the report page


<a href="abc" onclick="addcount()">Previous</a>
<a href="def" onclick="addcount()">Next</a>


for some reason my script is still keeping the value -1 after i click the previous or next link instead of increment -1, -2, -3



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum