Copy to clipboard not working in safari

时间:2016-09-01 06:31:34

标签: javascript html safari

copy on clipboard working in all browser but not working in safari code is

head>
    <title>copy test</title>
</head>
<body>
    <button onclick="copier()">Copy</button>
    <textarea id="myText">Copy me PLEASE!!!</textarea>

    <script>
        function copier(){
            document.getElementById('myText').select();
            document.execCommand('copy');
        }
    </script>
</body>
</html>

so for safari what i have to do please help me..thanks in advance.

1 个答案:

答案 0 :(得分:0)

这适用于“设计模式”。浏览器有效地将文档转换为编辑器。 execCommand API源自IE,后来被添加到HTML5中。确切支持哪些命令,以及它们的行为因浏览器而异。剪贴板访问被视为安全风险。

请查看此link