Hide URL parameters using HTML/HTML5

Before HTML5 we can use:

parent.location.hash = “hello”;
and:

window.location.replace(“http:www.example.com”);
This method will reload your page, but HTML5 introduced the history.pushState(page, caption, replace_url) that should not reload your page.

Eg: http://www.sampleurl.com?a=1&b=2

apply below code

<script>

window.onload=function(){

history.pushState(www.sampleurl.com?a=1&b=2,null, http://www.sampleurl.com)

}

output:

http://www.sampleurl.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s