尝试在chrome扩展程序中执行copyToClipboard函数时遇到错误。我不知道为什么会收到此错误,因为我制作了一个不同的js文件来运行该功能,并在html文件中添加了它。
The error is the following one
function copyToClipboard() {
/* Get the text field */
var clearing = 'Hola chicos'
/* Select the text field */
clearing.select();
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
}
<body>
<div class="modal-header">
<h1 class="logo">
<img src="images/meli-logo.png" alt="" class="logo-icon" style="width: 100px; height: 100px;"> ML Template Test
<div class="version">(1.0.0)</div>
</h1>
</div>
<div class="dropdown">
<button class="dropbtn">Retiros</button>
<div class="dropdown-content">
<button onclick="copyToClipboard()">Clearing</button>
</div>
</div>
</body>
这是我的清单
{
"manifest_version": 2,
"name": "MeliTemplates",
"version": "1.0.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": ["activeTab", "storage"]
}