url对象_URL对象

url对象

URL is a namespace used to host 2 static methods used to manipulate URLs using Blobs:

URL是一个命名空间,用于承载2个静态方法,这些静态方法用于使用Blob处理URL:

  • URL.createObjectURL()

    URL.createObjectURL()

  • URL.revokeObjectURL()

    URL.revokeObjectURL()

Given a blob, you generate a URL to it using the URL.createObjectURL() function:

给定一个Blob,您可以使用URL.createObjectURL()函数为其生成URL:

const myURL = URL.createObjectURL(aBlob)

Once you have the blob URL, you can destroy it from memory using:

拥有Blob URL后,可以使用以下方法从内存中销毁它:

URL.revokeObjectURL(myURL)


In addition to this, URL offers a very different functionality through its constructor, which can be used to create a URL. You can call it like this:

除此之外,URL通过其构造函数提供了非常不同的功能,可用于创建URL。 您可以这样称呼它:

const currentUrl = new URL(window.location.href)

Now currentUrl has a set of properties you can use to inspect the URL:

现在, currentUrl具有一组可用于检查URL的属性:

  • hash the hash fragment

    hash列哈希片段

  • host the domain + port

    host域+端口

  • hostname the domain

    hostname

  • href contains the entire URL

    href包含整个URL

  • origin scheme + domain + port

    origin方案+域+端口

  • password

    password

  • pathname

    pathname

  • port

    port

  • protocol

    protocol

  • search

    search

  • searchParams

    searchParams

  • username

    username

which are the usual parts of a URL.

这是网址的常见部分。

You can alter any of those, except origin and searchParams which are read only, and generate a new URL string by calling the toString() method, or by referencing the href property.

您可以更改所有这些内容(只读的originsearchParams除外),并通过调用toString()方法或引用href属性来生成新的URL字符串。

翻译自: https://flaviocopes.com/url/

url对象

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值