Set & Get Query Parameters In URL – hashparser

Category: Javascript | April 6, 2021
Author:rvanbaalen
Views Total:91 views
Official Page:Go to website
Last Update:April 6, 2021
License:MIT

Preview:

Set & Get Query Parameters In URL – hashparser

Description:

hashparser is a super tiny JavaScript library that helps you handle (set/get) query parameters in the URL.

How to use it:

1. Include the hashparser’s JavaScript on the page.

<script src="dist/hashparser.min.js"></script>

2. Append query parameters to the current URL.

HashParser.setParameter('css', 'script');
=> https://youtsite.com/page.html#!css=script

3. Determine whether to encode the query parameter value.

HashParser.setParameter(‘css’, ‘script’, true);

=> https://youtsite.com/page.html#!css=InNjcmlwdCI=

4. It supports any type of data in the hash.

var example = {
    "css": "script"
};
HashParser.setParameter('example', greeting, true);

5. Get the encoded value of a query parameter.

var getPara = HashParser.getParameter('css', true);

You Might Be Interested In:


Leave a Reply