js obtaining parameters corresponding to url

举例:http://localhost:5000/?sss=sdf&fdd=123

1, to set or get the entire URL string

window.location.href  

值:  http://localhost:5000/?sss=sdf&fdd=123

2, set or get the URL protocol part

window.location.protocol

Value: http:

3, set or get the host part of the URL

window.location.host

Value: localhost: 5000

4, set or get the port number associated with the URL

window.location.port

Value: 5000

5, set or get the path portion of the URL (the address is file)

window.location.pathname

value:/

6, a portion or retrieves the href attribute follows the question mark

window.location.search

Value:? Sss = sdf & fdd = 123

7, set or get the segment in the href attribute "#" after a pound sign

window.location.hash

: Empty

 

If in doubt you can leave a message.

Guess you like

Origin www.cnblogs.com/zxs-onestar/p/12082535.html