Last active
January 31, 2017 13:43
-
-
Save Nils-van-Kleef/643f1d24c42b27b3bcadc864e0efd6f9 to your computer and use it in GitHub Desktop.
Redirect: adds query-parameter at the end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* _optimizely_redirect=http://www.example.com */ | |
var qp_addition = "newSearchWeb=true"; | |
if (window.location.href.indexOf(qp_addition) < 0) { | |
var _optly = {redir: document.createElement("a")}; | |
_optly.redir = {protocol: "https:" == document.location.protocol ? "https://" : "http://", | |
domain: window.location.hostname, | |
entire_url: window.location.href, | |
query: window.location.search | |
}; | |
if (_optly.redir.query.length == 0) { | |
qp_addition = "?"+qp_addition; | |
} else { | |
qp_addition = "&"+qp_addition; | |
} | |
_optly.redir.href = _optly.redir.entire_url + qp_addition; | |
window.location.replace(_optly.redir.href); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment