Web - URL


An Uniform Resource Locator (URL) is a universal identifier for a resource.

It's the string that is understood by a browser when you put it in the address bar.

When the HTTP protocol is used as scheme, it's a identifier for a Web resource.

An URL was originally created to provide a method for finding an item such as a person's street address.

On a format level, the URL is a subset of an URI.

Mr. Berners-Lee, the creator of the Web’s bedrock software standards, would get rid of the double slash “//”after the “http:” in Web addresses. The double slash, though a programming convention at the time, turned out to not be really necessary, Mr. Berners-Lee explained.


scheme://[[email protected]]host[:port]/path?query#fragment






Lowest common denominator max URL length among popular web browsers is 2100 (Reference

How to get the url of the actual HTML page with Javascript

The value is stored in the href property

  • We used window.parent because the code is run in a iframe but in a normal page, you would just use window.
console.log("URL: "+window.parent.location.href); // url
// value is `about:srcdoc` because we are in a iframe
console.log("URL in iframe: "+window.location.href);
console.log("Path: "+window.parent.location.pathname);
console.log("Host: "+window.parent.location.host); 
  • hostname - only the name of the host (ie without the port)
console.log("Hostname: "+window.parent.location.hostname); 
console.log("Anchor: "+window.parent.location.hash);  
  • port (empty string if none)
console.log("Port: "+window.parent.location.port);  
console.log("Protocol: "+window.parent.location.protocol); 
console.log("Query String: "+window.parent.location.search);

Documentation / Reference

Powered by ComboStrap