js平时总结1

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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容