Team:TU Delft/header2
From 2010.igem.org
(Difference between revisions)
Line 37: | Line 37: | ||
$(function() { | $(function() { | ||
// Initialize history plugin. | // Initialize history plugin. | ||
- | $.history.init( | + | $.history.init(historyCallback); |
rewriteLinks($("#navlist")); | rewriteLinks($("#navlist")); | ||
Line 82: | Line 82: | ||
} | } | ||
- | function | + | function historyCallback(hash) { |
alert('historyCallback: ' + hash); | alert('historyCallback: ' + hash); | ||
// hash doesn't contain the first # character. | // hash doesn't contain the first # character. | ||
if(hash) { | if(hash) { | ||
- | + | if(hash.split('=').length == 1) { | |
- | + | alert('load hash as page: ' + hash); | |
loadPage(hash); | loadPage(hash); | ||
- | + | } else { | |
- | + | var kvmap = splitHash(hash); | |
- | + | if (kvmap.page) { | |
- | + | alert('load hashmap.page: ' + kvmap.page); | |
- | + | loadPage(kvmap.page); | |
- | + | } else if(kvmap.anchor) { | |
- | + | alert('scrolling to anchor: ' + kvmap.anchor); | |
- | + | window.scrollTo(0, $(kvmap.anchor).position().top); | |
- | + | } | |
- | + | } | |
} else { | } else { | ||
// start default page | // start default page |
Revision as of 13:26, 22 July 2010