Copy Web content automatically add website copyright information compatible IE Google Firefox

Source: Internet
Author: User

  1. var Sys = {};
  2. var ua = Navigator.userAgent.toLowerCase ();
  3. if (window. ActiveXObject)
  4. {
  5. Document.body.oncopy=function ()
  6. {
  7. Event.returnvalue = false;
  8. var t=document.selection.createrange (). text;
  9. var s= "\ r \ n Original from [Good Handsome personal blog] reproduced please keep the original link:" +LOCATION.HREF;
  10. Clipboarddata.setdata (' Text ', t+ ' \ r \ n ' +s);
  11. }
  12. }
  13. Else
  14. {
  15. function Addlink ()
  16. {
  17. var body_element = document.getelementsbytagname (' body ') [0];
  18. var selection;
  19. Selection = Window.getselection ();
  20. var pagelink = "Original from [Good Handsome personal blog] reproduced please keep the original link:" +DOCUMENT.LOCATION.HREF;
  21. var copytext = Selection + Pagelink;
  22. var newdiv = document.createelement (' div ');
  23. newdiv.style.position= ' absolute ';
  24. newdiv.style.left= ' -99999px ';
  25. Body_element.appendchild (NEWDIV);
  26. newdiv.innerhtml = CopyText;
  27. Selection.selectallchildren (NEWDIV);
  28. Window.settimeout
  29. (
  30. function ()
  31. {
  32. Body_element.removechild (NEWDIV);
  33. },0
  34. );
  35. }
  36. Document.oncopy = Addlink;
  37. }

Copy Web content automatically add website copyright information compatible IE Google Firefox

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.