首页 > 解决方案 > iframe 中如何禁用功能策略?

问题描述

我在复制文本的页面上有一个监听器。

obj['this'].shadowRoot.querySelector(`div.${item}`).addEventListener('click',async (event)=>{
 event.currentTarget.style.background = '#faf671'
 let object = event.currentTarget
 let value = object.querySelector('p.value').innerHTML
 await navigator.clipboard.writeText(value)
 let timer = setTimeout((event)=>{
     object.style.background = '#4c6499de'
     clearTimeout(timer);
   }, 250);
})

然后我在 iframe 中打开页面并收到此错误:

waves-provider.mjs:831 Uncaught (in promise) DOMException: Disabled in this document by Feature Policy.

我添加了允许

但在互联网上我看到了例子

allow="document-write https://www.google.com"
allow="fullscreen 'none'; geolocation 'none'"

但这是行不通的。

标签: javascript

解决方案


推荐阅读