User Tools

Site Tools


increment_decrement_uri

Increment/Decrement URI

Description

Increment/Decrement the last number in URI by one. For instance: Your visiting page http://www.host.com/?page=10, pressing ^a will guide you to http://www.host.com/?page=11. This can be useful for navigating forums and the like. Then decrementing, negative numbers are not supported, as this is not generally useful, so the number cannot be decremented past 0.

JavaScript

# Increments the last number in URI
@bind  = js (function () { var found = location.href.match(/(.*?)(\d+)([^\d]*)$/); if (found) { location = found[1] + (Number(found[2]) + 1) + found[3]; }})()

# Decrements the last number in URI
@bind  = js (function () { var found = location.href.match(/(.*?)(\d+)([^\d]*)$/); if (found && found[2] != "0") { location = found[1] + (Number(found[2]) - 1) + found[3]; }})()
increment_decrement_uri.txt · Last modified: 2016/08/31 14:10 (external edit)