IE and firefox general JS function copy to clipboard

1.function copyToClipboard (txt) (
2. If (window.clipboardData) (
3. Window.clipboardData.clearData ();
4. Window.clipboardData.setData ("Text", txt);
5.) Else if (navigator.userAgent.indexOf ("Opera")! = -1) (
6. Window.location = txt;
7.) Else if (window.netscape) (
8. Try (
9. ("UniversalXPConnect");
10.) Catch (e) (
11. Alert ("is your browser to refuse! \ N in the browser address bar enter 'about: config' and carriage return \ n then 'signed.applets.codebase_principal_support' set to 'true'");
13. Var clip = Components.classes ['@ / widget / clipboard; 1']. CreateInstance (Components.interfaces.nsIClipboard);
14. If (! Clip)
15. Return;
16. Var trans = Components.classes ['@ / widget / transferable; 1']. CreateInstance (Components.interfaces.nsITransferable);
17. If (! Trans)
18. Return;
19. Trans.addDataFlavor ('text / unicode');
20. Var str = new Object ();
21. Var len = new Object ();
22. Var str = Components.classes ["@ / supports-string; 1"]. CreateInstance (Components.interfaces.nsISupportsString);
23. Var copytext = txt;
24. = copytext;
25. Trans.setTransferData ("text / unicode", str, copytext.length * 2);
26. Var clipid = Components.interfaces.nsIClipboard;
27. If (! Clip)
28. Return false;
29. Clip.setData (trans, null, clipid.kGlobalClipboard);
30. Alert ("Copy succeeded!")

分类:Web 时间:2010-04-08 人气:674
blog comments powered by Disqus


  • js Firefox 加入收藏夹功能代码 兼容Firefox 和 IE 2013-10-04

    最近改用Firefox后,发现很多网站的"加入收藏"链接点击无效了,后来发现原来是IE浏览器和Firefox浏览器的"加入收藏夹"的写法是不同的. 完整代码如下:chrome下也有提示,说实话一般这类代码一般都是IE下使用,其它浏览器也只是给个提示了. <script type="text/javascript"> //设为首页 function SetHome(obj,url){ try{ obj.styl

  • FCKEditor carriage return line feed problem 2010-07-19

    Modify FCKeditor / fckconfig.js Found FCKConfig.EnterMode = 'p'; / / p | div | br said <p> tagged with carriage return line feed FCKConfig.ShiftEnterMode = 'br'; / / p | div | br said shifit + carriage return line feed Tag with <br> Want to us

  • 无间断滚动的新闻文章列表,兼容IE.Firefox和Opera,符合W3C标准.可作Marquee 2014-04-23

    <!--Quirks Mode--> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ""> <html xmlns=""> <head> <meta http-equiv=&

  • JSF tag <f:param/> not have to pass the value of the carriage return! 2010-02-07

    Hello All, JSF <f:param value=""/> tag value value can not have a carriage return, If there is a carriage return will affect the page display, nor reported any errors. Deal with tricks up their sleeves for you brother. Thanks ..

  • JPA handle carriage return problem! 2010-02-07

    Hello All, Add carriage return character to use JPA feasible, but Optimistic lock, the query out, and then deleted, Will be reported [Reason = <openjpa-1.1.0-r422266:657916 nonfatal store error> org.apache.openjpa.util.OptimisticException: Optimisti

  • ie, chrome, firefox, safari, opera html5 2008-07-31

    When the Ming among mainstream browsers chrome, firefox, safari, opera have been supported or are prepared to support HTML5, only ie does not support, for good or MS disappointed! html5 Usage: html5: Effect Demo: htt

  • Carriage return and line feed 2010-03-17

    Plan a lot to learn regular expressions, so first figure out some basic concepts, starting with a carriage return and line start The following is an excerpt from Ruan Yifeng's blog Wrote, Today, I

  • How to add a carriage return in the event page 2010-04-02

    The content is purely on-line data collection, not original, I hope to help people in need. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html xmlns=

  • sql server replace the carriage return symbols in 2010-04-16

    replace (replace (TrainAcquaintance.Comment, char (10 ),''), char (13 ),'') char (13) is represented by a carriage return

  • Carriage return line feed (\ r \ n) order 2010-04-20

    Subject: carriage return, line feed! Environment: Window The keyboard "Enter" key to almost no one does not know, something well-known, carriage return, line feed many people and remembered very difficult to talk normally, but specific to text p

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.039 (s). 11 q(s)