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 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2005
    Location
    Near some trees
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    1 line of code required

    Instead of having a link on page 1 which takes you to page 2, and a link on page 2 which takes you to page 3...

    Is there a line that I can use which can be same on all of the pages. A link that says choose the next pagename.html in sequence?

    Thanks in advance

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Code:
    function next() {
        /\/([^\/\d]+)(\d+)\.html$/.exec(location.href);
        location.href = RegExp.$1 + (parseInt(RegExp.$2,10)+1) + ".html";
    }
    As long as your page filenames only have digits immediately before .html, that should probably do the trick.


  •  

    Posting Permissions

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