zoukankan      html  css  js  c++  java
  • Feature Police导致iframe页面无法使用粘贴功能

    说明

    在Chrome 81版本之上时,通过iframe引入的页面无法正常使用粘贴板。此时,控制台会输出

    DOMException: The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://goo.gl/EuHzyv for more details.
    

    错误,这是由于web规范之Feature Police导致的。

    Feature Police有些类似于CSP,是安全策略的一种。关于FP的设置有两种,Headers设置与iframe的属性(allow)设置,目前常用的的Feature类型可参考:Features,也可以在浏览器执行

    document.featurePolicy.allowedFeatures();
    

    获取当前版本浏览器支持的类型。

    解法

    针对iframe无法使用粘贴板的问题,可采用

    <iframe id = 'ide' allow="clipboard-read; clipboard-write " src = "xxx"></iframe>
    

    加上allow属性即可。

  • 相关阅读:
    算法之冒泡排序
    实现秒杀的几个想法(续)
    乐观锁
    wifi-sdio接口
    解压vmlinuz和解压initrd(initramfs)
    supplicant
    wpa_supplicant测试
    qu
    netlink
    wpa_supplicant安装
  • 原文地址:https://www.cnblogs.com/accordion/p/14784047.html
Copyright © 2011-2022 走看看