String.prototype.blink()

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

String 值的 blink() 方法创建一个字符串,将该字符串嵌入到 <blink> 元素 (<blink>str</blink>) 中,这通常会导致字符串在旧浏览器中闪烁。

¥The blink() method of String values creates a string that embeds this string in a <blink> element (<blink>str</blink>), which used to cause a string to blink in old browsers.

注意:所有 HTML 封装方法 均已弃用,仅出于兼容性目的而进行标准化。对于 blink() 的情况,<blink> 元素本身已从现代浏览器中删除,并且多个可访问性标准不赞成闪烁文本。避免以任何方式使用该元素。

¥Note: All HTML wrapper methods are deprecated and only standardized for compatibility purposes. For the case of blink(), the <blink> element itself is removed from modern browsers, and blinking text is frowned upon by several accessibility standards. Avoid using the element in any way.

语法

¥Syntax

js
blink()

参数

¥Parameters

没有任何。

¥None.

返回值

¥Return value

<blink> 开始标记开始的字符串,然后是文本 str,最后是 </blink> 结束标记。

¥A string beginning with a <blink> start tag, then the text str, and then a </blink> end tag.

示例

¥Examples

使用眨眼()

¥Using blink()

下面的代码创建一个 HTML 字符串,然后用它替换文档的正文:

¥The code below creates an HTML string and then replaces the document's body with it:

js
const contentString = "Hello, world";

document.body.innerHTML = contentString.blink();

这将创建以下 HTML:

¥This will create the following HTML:

html
<blink>Hello, world</blink>

警告:此标记无效,因为 blink 不再是有效元素。

¥Warning: This markup is invalid, because blink is no longer a valid element.

你应该完全避免闪烁元素。

¥You should avoid blinking elements altogether.

规范

Specification
ECMAScript Language Specification
# sec-string.prototype.blink

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看