以下是来自 Google Bard 对其工作原理的解释:
The code data:text/html;base64,PGh0bWwgY29udGVudGVkaXRhYmxlPmVkaXQgbWU8L2h0bWw+ in a browser URL is a data URI scheme. It is a way of embedding a small amount of data, such as text, images, or CSS, directly into a web page. This can be useful for things like embedding a small logo or tracking pixel into a page, or for providing fallback content for users who cannot load external resources.
The data URI scheme is defined by the following syntax:
Code snippet
data:[<media type>][;base64],<data>
Use code with caution. Learn more
The <media type> is a string that identifies the type of data being embedded. The <data> is the actual data, encoded in base64.
In the example you provided, the <media type> is text/html and the <data> is the HTML code for a simple page. This page contains a heading and a paragraph of text.
When a browser encounters a data URI, it will decode the base64 data and then treat it as if it had been loaded from an external resource. In this case, the browser will load the HTML code and display it as a web page.
Data URIs can be a useful way to embed small amounts of data into web pages. However, they should be used sparingly, as they can increase the size of the page and make it slower to load.
Here are some additional things to keep in mind when using data URIs:
The maximum size of a data URI is 32KB.
Data URIs are not supported by all browsers.
Data URIs can be used to embed malicious code.
If you are considering using data URIs, it is important to weigh the benefits and drawbacks carefully.