javascript - 复制到剪贴板在 safari 中不起作用

标签 javascript jquery html iframe clipboard.js

下面是我“复制到剪贴板”的代码,除了不能在 safari 浏览器上运行外,一切正常...请帮忙

<textarea id="mcq1" style="width:1px; height:1px; opacity:0; position:absolute;">
    <iframe src="http://s.rabblerapp.com/widget/widget.php?raw_uuid=de8c6880-9624-4b1d-8905-a3e2ab290660" style="width:100%;height:635px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0"></iframe>
</textarea>

<button class="rb_mcqbtn btn" data-clipboard-action="copy" data-clipboard-target="#mcq1" onclick="show_area('copied');">Copy Embed Code</button>

这是我为此使用的 javascript... https://zenorocha.github.io/clipboard.js

最佳答案

我看了他们的网站..

看这里:link

This library relies on both Selection and execCommand APIs. The second one is supported in the following browsers.

images here.....

Although copy/cut operations with execCommand aren't supported on Safari yet (including mobile), it gracefully degrades because Selection is supported.

关于javascript - 复制到剪贴板在 safari 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34254318/

相关文章:

javascript - addclass() 在控制台中工作但在脚本中不起作用

javascript - 如何使用react hooks清理useEffect中的setInterval

javascript - 如何在 Pug 中渲染详细 View 而不是其所有对象?

javascript - 如何使用数据表在表格上显示更少的文本?

html - 文本底部的几个像素被截断

javascript - 是否有一种客户端方法可以防止图像被缓存?

javascript - 在具有全高页面的javascript中获取滚动事件

Jquery - 按类获取下一个元素并隐藏当前元素

jquery - 检查函数是否动态存在

jquery - 如何使用jquery从html表格中重新排序空白单元格