// Code borrowed from: http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript function getParameterByName(name, url) { if (!url) url = window.location.href; url = url.toLowerCase(); // This is just to avoid case sensitiveness name = name.replace(/[\[\]]/g, "\\$&").toLowerCase();// This is just to avoid case sensitiveness for query parameter name var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } function redirect(newUrl) { var n0 = getParameterByName("n0"); var n1 = getParameterByName("n1"); var n2 = getParameterByName("n2"); var p0 = getParameterByName("p0"); var fb_comment_id = getParameterByName("fb_comment_id"); if (fb_comment_id) newUrl += "fb_comment_id=" + fb_comment_id; else { if (n0) newUrl += "n0=" + n0; if (n1) newUrl += "&n1=" + n1; if (n2) newUrl += "&n2=" + n2; if (p0) newUrl += "&p0=" + p0; } window.location.href = newUrl; }