From 998b963eb6fc7719e74e5d89926653f60f693ee1 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Sun, 19 Apr 2015 18:59:50 +0300 Subject: [PATCH] Firefox fix for #code --- dukweb/dukweb.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dukweb/dukweb.html b/dukweb/dukweb.html index 2017502c..45c08003 100644 --- a/dukweb/dukweb.html +++ b/dukweb/dukweb.html @@ -80,6 +80,8 @@ function dukwebSetup() { dukwebOutput = []; var code = $('#dukweb-input').val(); if (code.length < 65536 && location) { + // Although Firefox automatically decodes location.hash, this + // still seems to work. location.hash = encodeURIComponent(code); } setTimeout(function () { @@ -95,9 +97,18 @@ function dukwebSetup() { $(document).ready(function () { function checkUriCode() { + // In some browsers location.hash is automatically decoded and in + // others it is not. This is more portable: + // http://stackoverflow.com/questions/4835784/firefox-automatically-decoding-encoded-parameter-in-url-does-not-happen-in-ie + if (location && location.href && location.href.indexOf('#') >= 0) { + var code = location.href.substring(location.href.indexOf('#') + 1); + $('#dukweb-input').val(decodeURIComponent(code)); + } +/* if (location && location.hash && location.hash[0] === '#') { $('#dukweb-input').val(decodeURIComponent(location.hash.substring(1))); } +*/ } try { checkUriCode();