Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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)

    Code:
    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.
    Last edited by knightsjoker; 12-02-2009 at 04:07 PM. Reason: add code

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    not allowed to use direct url otherwise i would have done so.

    i've changed the code a bit...

    Code:
    <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
    Code:
    <a href="javascript:glisting()">Back to listing</a>
    the code below is the pagination on the detailed view of the report page
    Code:
    <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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •