Home >Web Front-end >HTML Tutorial >Can we remove the 'getContext' attribute of HTML5 Canvas tag through script?

Can we remove the 'getContext' attribute of HTML5 Canvas tag through script?

王林
王林forward
2023-09-03 19:21:021021browse

我们能通过脚本删除HTML5 Canvas标签的“getContext”属性吗?

It is not stated in the HTML5 specification that it is valid for scripts to delete the getContext attribute.

We can write a piece of code that removes the getContext property of HTMLCanvasElement and then in a separate statement we set it to undefined.

Delete window.HTMLCanvasElement.prototype.getContext;

_assertSame(window.HTMLCanvasElement.prototype.getContext, undefined,
   "window.HTMLCanvasElement.prototype.getContext", "undefined");

The above is the detailed content of Can we remove the 'getContext' attribute of HTML5 Canvas tag through script?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete