1.js中提供了3对函数用来对Url编码以得到合法的Url,它们分别是escape / unescape, encodeURI / decodeURI和encodeURIComponent / decodeURIComponent
所谓合法就是不产生歧义,
encodeURIComponent 生成, decodeURIComponent 解析
2.url结构
* 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.
网友评论