Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click a webpage's Next button via Javascript Web Browsers
Sites such as macosxhints and the OS X page at iusethis.com, and many other great webpages, put a Next button down at the bottom of the page, so you can see the next webpage in the sequence. Sometimes, on a busy page, it's a little difficult to find. This hint gives allows you to define a bookmark that will hit that Next button automagically.

The idea is to pop the following snippet of javascript into the bookmark's address:
javascript:
var contents=document.links;
var regexp = /next/i;
for (i = contents.length - 1; i >= 0; i--) {
  possURL = regexp.exec(contents[i].text);
  if (possURL != null) {
    self.location=contents[i].href;
  }
}
Copy everything from javascript to the last }. Next, show all bookmarks, create a new bookmark (call it "Next button"), edit its address (contextual menu action), and paste the above Javascript into its address field. When you leave the address field, the formatting will disappear, and everything will be on one line, with %20 where spaces used to be. The code will still work though. If you've created the bookmark in the bookmark bar, you'll have a button at the top of every webpage to click.

How it works: The Javascript searches all links in the page, from the end to the top, looking for one with the text "next" in it. If it finds it, it loads the referenced page. I don't know Javascript, and there's probably much more that could be done in more elegant ways. It doesn't work with all pages, but that could probably be fixed too.

[robg adds: I tested this, and it works well on the macosxhints pages.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[11,592 views]  

Click a webpage's Next button via Javascript | 12 comments | Create New Account
Click here to return to the 'Click a webpage's Next button via Javascript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Click a webpage's Next button via Javascript
Authored by: bex on Sep 20, '06 08:39:53AM

Don't forget though, it "clicks" the first next button it finds. Right now that means that "next" off of the macosxhints homepage is a link to this article :D



[ Reply to This | # ]
Click a webpage's Next button via Javascript
Authored by: iPinto on Sep 20, '06 12:17:34PM
Maybe changing this line
var regexp = /next/i;
to this
var regexp = /^next$/i;
should do the work. I am not on my mac now so I can't tell.

[ Reply to This | # ]
Click a webpage's Next button via Javascript
Authored by: dolphy on Sep 20, '06 09:13:30AM

You say "edit its address (contextual menu action), and paste the above Javascript into its address field. When you leave the address field, the formatting will disappear, and everything will be on one line."

I've tried this in Firefox (pasting the script into the Location window) but the only line that appears is the first. I get a whole list of errors in the Javascript console after clicking on the button thereafter.

Am I totally misunderstanding this tip? Please advise.

---
dolphy



[ Reply to This | # ]
Click a webpage's Next button via Javascript
Authored by: dolphy on Sep 20, '06 11:30:02AM

I can confirm that the hint works for Safari & does not work for Firefox. I can't speak for other browsers, but the applicability of this hint should have been made clear from the outset.

That said, it's a nice addition in Safari...

---
dolphy



[ Reply to This | # ]
Click a webpage's Next button via Javascript
Authored by: jamagic on Sep 20, '06 01:46:50PM
This hint still works in Firefox. You just have to manually remove any line/paragraph breaks. Check out this link:

http://www.tutorialized.com/tutorial/Using-Javascript-and-Bookmarks-to-create-custom-searches-on-your-toolbar/14530

"Unfortunately, bookmark links alow only one line of code, and in order to properly let the bookmark know we want to execute javascript, we have to put the javascript: protocol infront of the code. In order to get it into one single line, simply hit delete at the end of every line (without erasing any code). In order to let it know we are executing javascript, make sure you put the javascript: protocol before the entire line."

[ Reply to This | # ]

Click a webpage's Next button via Javascript
Authored by: kkL on Sep 20, '06 09:40:19AM

Or just use Opera Browser which has that feature built-in and much smarter (recognizes more link texts and {link} element in {head})

In Opera just hold space (or "Fast Forward" button) - it will scroll down and then go to next page. It can also find links to .JPGs on page and make a slideshow.



[ Reply to This | # ]
Click a webpage's Next button via Javascript
Authored by: ryebrye on Sep 20, '06 12:22:28PM

It gets even better if you use mouse gestures - just Right-click and move the mouse to the right and it will go to the next page... It is cool how it will find links like "Next" or if a page has numbers on the bottom it will just advance to the next numbered page... (Same with images - if you are viewing JPGs that originate from one main site, on the JPG itself you can fast forward and Opera will intelligently remember what page you came from and move to the next image on that index...)

In short - Opera is the best all around web browser...



[ Reply to This | # ]
Click a webpage's Next button via Javascript
Authored by: hPa on Sep 20, '06 12:28:57PM

That's a great hint! Since there is a keyboard shortcut for each bookmarks in the bookmarks bar (e.g. Cmd-3 for the 3rd bookmark) I can now search discussions or Google results much faster with one hand on the scoll wheel of my mouse and the other hand on the keyboard....



[ Reply to This | # ]
Click a webpage's Next button via Javascript
Authored by: JKT on Sep 20, '06 02:44:52PM
...or if you use OmniWeb just press the enter key (which is the built-in default for the same feature - note that is Enter and not Return).

---
PB G4, 1.5 GHz, 1.5GB RAM, 128MB VRAM, 80 GB 5400rpm HD, SuperDrive, MacOS X 10.4.7

Visit www.thelandgallery.com for nature-inspired British Art

[ Reply to This | # ]

Click a webpage's Next button via Javascript
Authored by: kreatix on Sep 20, '06 05:43:33PM

Is there some way to edit this script so it will first look for english "next" and then look for the word "next" in a second language?



[ Reply to This | # ]
Click a webpage's Next button via Javascript
Authored by: ra5ul on Sep 20, '06 07:28:09PM

many browsers have this functionality. opera and omniweb having already been covered...

safari: use saft (it's bound to the enter key), or pithHelmet's alphakeys rule (bound to C-l).

firefox: use the NextPlease! extension (this is the strongest one, imho, for any browser).



[ Reply to This | # ]
Click a webpage's Next button via Javascript
Authored by: flunkedflank on Sep 20, '06 09:26:34PM

Yes! You beat me to it: NextPlease! for Firefox is awesome. I installed it a few months ago and have been wondering how I lived so long without it.



[ Reply to This | # ]