Add Custom Parameter To URL - jQuery PushDataToUrl

Add Custom Parameter To URL - jQuery PushDataToUrl

PushDataToUrl is a small jQuery plugin which enables the developers to dynamically append parameters (key/value) to the current URL without refreshing the page.

1. Install & download.

# NPM
$ npm install push-data-to-url --save

2. Load the pushToUrl.jQuery.js script from the src folder.

<script src="https://code.jquery.com/jquery-3.4.0.slim.min.js" 
        integrity="sha384-7WBfQYubrFpye+dGHEeA3fHaTy/wpTFhxdjxqvK04e4orV3z+X4XC4qOX3qnkVC6" 
        crossorigin="anonymous">
</script>
<script src="./src/pushToUrl.jQuery.js"></script>

3. Or from the CDN.

<script src="https://code.jquery.com/jquery-3.4.0.slim.min.js" 
        integrity="sha384-7WBfQYubrFpye+dGHEeA3fHaTy/wpTFhxdjxqvK04e4orV3z+X4XC4qOX3qnkVC6" 
        crossorigin="anonymous">
</script>
<script src="https://unpkg.com/push-data-to-url"></script>

4. Add key/value to the URL.

$('body').pushToUrl('add', {
  key: 'jqueryscript', 
  value: '12345'
});

5. Remove a specific parameter from the URL.

$('body').pushToUrl('removeSelected', {
  key: 'jqueryscript'
});

6. Remove all parameters from the URL..

$('body').pushToUrl('removeAll');

This awesome jQuery plugin is developed by baralmanish. For more Advanced Usages, please check the demo page or visit the official website.

  • Publication date: 17.04.2019
  • Source