Skip to content

Instantly share code, notes, and snippets.

@cengiz-demir
Last active April 15, 2017 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cengiz-demir/905fb964760aa547f3386b66b511f363 to your computer and use it in GitHub Desktop.
Save cengiz-demir/905fb964760aa547f3386b66b511f363 to your computer and use it in GitHub Desktop.
Javascript Basic Structure of a URL
<protocol>//<hostname>:<port>/<pathname><search><hash>
Protocol -- Specifies the protocol name be used to access the resource on the Internet. (HTTP (without SSL) or HTTPS (with SSL))
hostname -- Host name specifies the host that owns the resource. For example, www.stackoverflow.com. A server provides services using the name of the host.
port -- A port number used to recognize a specific process to which an Internet or other network message is to be forwarded when it arrives at a server.
pathname -- The path gives info about the specific resource within the host that the Web client wants to access. For example, /index.html.
query -- A query string follows the path component, and provides a string of information that the resource can utilize for some purpose (for example, as parameters for a search or as data to be processed).
hash -- The anchor portion of a URL, includes the hash sign (#).
With these Location object properties you can access all of these URL components
hash - Sets or returns the anchor portion of a URL.
host - Sets or returns the hostname and port of a URL.
hostname - Sets or returns the hostname of a URL.
href - Sets or returns the entire URL.
pathname - Sets or returns the path name of a URL.
port - Sets or returns the port number the server uses for a URL.
protocol - Sets or returns the protocol of a URL.
search - Sets or returns the query portion of a URL
<a href="http://stackoverflow.com/questions/1034621/get-current-url-in-web-browser">Thanks</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment