SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    239
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post I need a script for auto generating next and prev buttons

    I'm trying to do something like this:
    Code:
    if (this.url=='page2.html'){
    document.write('<input type=button value="next" onclick="this.url='page3.html'">');
    document.write('<input type=button value="prev" onclick="this.url='page1.html'">');
    }
    That doesn't work for starters, but more than that I want to be able to access the page name, "page2" in this case, extract the number and then use it to auto generate the next and back buttons.

    I'm finding this hard. I'm sure this is a common script type, but I can't find out how to do it. Can anyone help?

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this.url doesn't mean anything to me- did you define it to mean the document.title, or the file name part of the location.href?

  3. #3
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    239
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Sadly my JavaScript book is not with me so I cannot remember how to access the file name part of location.href, which is what I wanted to do.

    Do you know of an online JavaScript resource that's as good as the W3C CSS one? I can't find anything I can use as well as my O'Reilly book.

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually this is not a normal JavaScript script type. Most people would use a server-side language to generate those.

    I am concerned that your code is not following JavaScript Best Practices. I recommend you read up on them.

    As far as references, here are some good ones:
    http://developer.mozilla.org/en/docs/JavaScript
    Mozilla JavaScript and DOM Reference
    http://www.devguru.com/technologies/...ipt_index.html
    http://www.quirksmode.org/
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    239
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If I had it my way the site would be done in PHP but I'm only creating the site, I don't have control over the hosting deal.

    Thanks for the links.


Bookmarks

Posting Permissions

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