There is no native way to do this, but what you can do is define a separator between the ID and the offset, e.g. /
, then parse it out.
For example:
/path/to/page#id/200
Then you can parse the value out and manually move it forward. Note that I don't know how to trigger this as an event if you're already on the page and moving to an anchor on the page (please fill me in anyone?)
function moveToHash() {
function offset(node) {
var x = 0, y = 0; do {
x += node.offsetLeft;
y += node.offsetTop;
} while (node = node.offsetParent);
return {x: x, y: y};
}
var id = location.search.match(/([^\/]+)/)[1];
var offset = location.search.match(/\/(.+)/)[1] * 1;
var nodeOffset = offset(document.getElementById(id));
window.scrollTo(nodeOffset.x, nodeOffset.y);
window.scrollBy(0, offset);
}