From 0c04d149649b43aba397b5aa18a7b967463c8665 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Wed, 6 May 2015 10:45:05 -0400 Subject: [PATCH] Preserve history when linking --- js/scratchx.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/scratchx.js b/js/scratchx.js index 17db185..5286c20 100644 --- a/js/scratchx.js +++ b/js/scratchx.js @@ -129,7 +129,12 @@ $("[data-action='load-url'] button").click(function(e) { $("[data-staticlink]").click(function(e) { e.preventDefault(); - showPage($(this).attr("data-staticlink")); + var path = $(this).attr("data-staticlink"); + showPage(path); + window.location.hash = $(this).attr('href'); + if ($("body > main > article").has(path).length == 0) { + document.body.scrollTop = 0; + } }); function showPage(path) {