Get current url port, hostname and path in JavaScript

window.location is an Object with properties of current location namely

window.location.href returns the href url of the current page

window.location.hostname returns the domain name

window.location.pathname returns the pathname segment of the url

window.location.protocol returns the web protocol of the url

window.location.assign() loads a new document

Comments

Popular posts from this blog

FlappingBird Postmortem (JS13K)

JavaScript introduction to variables

FlappingBird JS13K Games

How to target all elements of a given class name in JavaScript

Zedplug will be decommissioned on November 30th