admin管理员组文章数量:1310404
Below is my code to "copy to clipboard" everything is workingfine with except its not working on safari browser... please help
<textarea id="mcq1" style="width:1px; height:1px; opacity:0; position:absolute;">
<iframe src=".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>
This is javascript i have use for this... .js
Below is my code to "copy to clipboard" everything is workingfine with except its not working on safari browser... please help
<textarea id="mcq1" style="width:1px; height:1px; opacity:0; position:absolute;">
<iframe src="http://s.rabblerapp./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>
This is javascript i have use for this... https://zenorocha.github.io/clipboard.js
Share Improve this question edited Dec 26, 2015 at 18:55 Zeno Rocha 3,5861 gold badge25 silver badges27 bronze badges asked Dec 13, 2015 at 17:53 varun tanwarvarun tanwar 331 gold badge1 silver badge4 bronze badges 2- hi if i give a code to copy a text without any plugin will it work for you – Tanmay Commented Dec 13, 2015 at 18:01
-
It appears the Safari 10 is now supporting
document.execCommand("copy")
so that clipboard.js should work in the newest Safari now. – jfriend00 Commented Jun 24, 2016 at 16:36
2 Answers
Reset to default 4I had a look at their site..
Look here: 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.
I agree to review their docs and create a solution that works for you but this is what I came up with as a simple fallback. Allows you to not have to use a 3rd party tipsy library. I just toggle the target text.
var CopytoClipboard = new Clipboard('.clipboard-copy'); CopytoClipboard.on('success', function(e) { var $target = $(e.trigger); var oText = $target.html(); $target.html("Copied!"); setTimeout(function () { $target.html(oText); }, 800); }); CopytoClipboard.on('error', function(e) { var $target = $(e.trigger); var oText = $target.html(); $target.html("Press ⌘C to copy"); setTimeout(function () { $target.html(oText); }, 3000); });
本文标签: javascriptCopy to Clipboard is Not Working in safariStack Overflow
版权声明:本文标题:javascript - Copy to Clipboard is Not Working in safari - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741828802a2399808.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论