Last active
September 30, 2017 01:27
-
-
Save sarnobat/da32d0a07efc5427f3c6908420920ece to your computer and use it in GitHub Desktop.
Get and Set URL parameter in javascript
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
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/purl/2.3.1/purl.js"></script> | |
<script> | |
// Get the URL parameter | |
var argName = $.url().param('argName'); | |
// Set the URL parameter | |
if (argName == null) { | |
history.pushState(null, null, '/?argName=defaultValue'); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment