clearMarks() method removes the named mark from the browser's performance entry buffer. If the method is called with no arguments, all performance entries 采用 entry type of " mark " will be removed from the performance entry buffer.

注意: 此特征可用于 Web 工作者 .

句法

performance.clearMarks();
performance.clearMarks(name);
					

自变量

名称 可选
DOMString representing the name of the timestamp. If this argument is omitted, all performance entries 采用 entry type of " mark " will be removed.

返回值

void

范例

The following example shows both uses of the clearMarks() 方法。

// Create a small helper to show how many PerformanceMark entries there are.
function logMarkCount() {
  console.log(
    "Found this many entries: " + performance.getEntriesByType("mark").length
  );
}
// Create a bunch of marks.
performance.mark("squirrel");
performance.mark("squirrel");
performance.mark("monkey");
performance.mark("monkey");
performance.mark("dog");
performance.mark("dog");
logMarkCount() // "Found this many entries: 6"
// Delete just the "squirrel" PerformanceMark entries.
performance.clearMarks('squirrel');
logMarkCount() // "Found this many entries: 4"
// Delete all of the PerformanceMark entries.
performance.clearMarks();
logMarkCount() // "Found this many entries: 0"
					

规范

规范 状态 注释
User Timing Level 2
The definition of 'clearMarks()' in that specification.
工作草案 Clarifies clearMarks() .
User Timing
The definition of 'clearMarks()' in that specification.
推荐 Basic definition.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
clearMarks Chrome 29
29
25 — 29 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 41 IE 10 Opera 33 Safari 11 WebView Android ≤37
≤37
≤37 — ≤37 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android 29
29
25 — 29 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 42 Opera Android 33 Safari iOS 11 Samsung Internet Android 2.0
2.0
1.5 — 2.0 Prefixed
Prefixed Implemented with the vendor prefix: webkit

图例

完整支持

完整支持

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

元数据

  • 最后修改:
  1. 性能
  2. 特性
    1. navigation
    2. onresourcetimingbufferfull
    3. timeOrigin
    4. timing
  3. 方法
    1. clearMarks()
    2. clearMeasures()
    3. clearResourceTimings()
    4. getEntries()
    5. getEntriesByName()
    6. getEntriesByType()
    7. mark()
    8. measure()
    9. now()
    10. setResourceTimingBufferSize()
    11. toJSON()
  4. 事件
    1. resourcetimingbufferfull
  5. Related pages for User Timing API
    1. PerformanceEntry
    2. PerformanceMark
    3. PerformanceMeasure

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1