/**
* Get URL and URL Parts in JavaScript
*
* @author Chris Coyier
* @link https://css-tricks.com/snippets/javascript/get-url-and-url-parts-in-javascript/
*/
window.location.protocol = "http:"
window.location.host = "your-website.com"
window.location.pathname = "example/index.html"
/**
* http://your-website.com/example/index.html
*/
window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
Just wanted to share a snippet by Chris Coyier that I've used a million times over and over in all of my projects.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.