JavascriptSnippets

On Page Load Append Param to URL

By May 30, 2020No Comments

Basically just append a parameter to the location (URL) when page loads. In the example below I am including a WordPress page title in the URL.

var your_message = <?php echo json_encode(get_the_title());?>;
if(window.location.search.indexOf('?') === -1) {window.location.search += '&amp;your-message=I would like to learn more about your '+your_message+' :)';}

Contact us to learn about adopting the web for your business

Jarod Thornton

Author Jarod Thornton

More posts by Jarod Thornton