1.js中提供了3對函數(shù)用來對Url編碼以得到合法的Url辜妓,它們分別是escape / unescape, encodeURI / decodeURI和encodeURIComponent / decodeURIComponent
所謂合法就是不產(chǎn)生歧義致板,
encodeURIComponent 生成蚓让, decodeURIComponent 解析
2.url結(jié)構(gòu)
* protocol: The protocol scheme of the URL (e.g. http:).
* slashes: A boolean which indicates whether the protocol is followed by two forward slashes (//).
* auth: Authentication information portion (e.g. username:password).
* username: Username of basic authentication.
* password: Password of basic authentication.
* host: Host name with port number.
* hostname: Host name without port number.
* port: Optional port number.
* pathname: URL path.
* query: Parsed object containing query string, unless parsing is set to false.
* hash: The "fragment" portion of the URL including the pound-sign (#).
* href: The full URL.
* origin: The origin of the URL.