window.location in javascript

Please find below code…

//Get current page url
var curr_url = window.location.href

//Get hostname
var host_name = window.location.hostname

//Display the path name of the current URL
var path_name = window.location.pathname

//Get protocol of URL return http:// or https://
var proto = window.location.protocol;

//Get parameters from URL
var x =;


Leave a Reply

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

You are commenting using your 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 )

Connecting to %s