blob: 9faf7a2ae17c40ac997ec63c61c02b242be68e18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// Copyright (c) 2009-2011 by Kris Maglione <kris@vimperator.org>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
"use strict";
function checkFragment() {
document.title = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "title")[0].textContent;
function action() {
content.scrollTo(0, content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context
}
var frag = document.location.hash.substr(1);
if (frag) {
var elem = document.getElementById(frag);
if (elem) {
action();
setTimeout(action, 10);
}
}
}
document.addEventListener("load", checkFragment, true);
document.addEventListener("hashChange", checkFragment, true);
// vim: set fdm=marker sw=4 ts=4 et:
|