Get parameters from URL address

In the browser host environment, there is a host object, which is also an attribute of the window object and the document object. The location object provides information about the document loaded in the current window, that is, URL information;

Such as: https://www.baidu.com/api/sousu?search=baidu&id=123#2

  • location.herf: full URL

  • location.protocol: return protocol (https:)

  • location.host: return the server name and port number (www.baidu.com)

  • location.hostname: return the server name (www.baidu.com)

  • location.port: returns the server port number (default is 80 for http, 443 by default for https)

  • location.pathname: returns the directory and file name in the URL (api/sousu)

  • location.search: Return the query string (?search=baidu&id=123#2)

  • location.hash: return the hash value (#2)

Guess you like

Origin blog.csdn.net/weixin_43131046/article/details/115090924