Created
March 8, 2016 08:11
-
-
Save oscarandreu/c2bd145c33149a00274b to your computer and use it in GitHub Desktop.
Redirect to url parameter URL via javascript
This file contains hidden or 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
| function getQueryParams(qs) { | |
| qs = qs.split('+').join(' '); | |
| var params = {}, | |
| tokens, | |
| re = /[?&]?([^=]+)=([^&]*)/g; | |
| while (tokens = re.exec(qs)) { | |
| params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); | |
| } | |
| return params; | |
| } | |
| //file:///C:/Users/OscarA/Desktop/getAjax.html?url=http://www.google.com?id=52435325 | |
| var query = getQueryParams(document.location.search); | |
| console.log(query.url); | |
| window.location = query.url; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment