Get URL Window Location

var _host = window.location.host; var _hostName = _host.substring(_host.indexOf(".")+1); var _href = window.location.href; var _pathName = window.location.pathname; var _lastIndex = _href.substring( _href.lastIndexOf( "/" )+1 ); console.log( '\n\n*******\n\n'+'HOST : '+_host+'\n'+'HOSTNAME : '+_hostName+'\nHREF : '+_href+'\nPATHNAME : '+_pathName+'\nLASTINDEX : '+_lastIndex+'\n\n*******\n\n' );

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.