Phill Sparks

JS Page Navigation

function go(rel) {
	var url;
	if (url = document.evaluate('//*[@rel="' + rel + '"]/href', document, null, XPathResult.STRING_TYPE, null)).stringValue) {
		window.location.href = url;
		return true;
	}
	return false;
}

function goFirst() {
	go('first') || alert('No first found.');
}
function goPrevious() {
	go('prev') || go('previous') || alert('No previous found.');
}
function goNext() {
	go('next') || alert('No next found.');
}
function goLast() {
	go('last') || alert('No last found.');
}

Created by Phill Sparks on 21st May 2008. Last updated on 9th October 2011.