Js copies webpage content and is compatible with the code of mainstream browsers
There are a lot of methods for js to copy webpage content, but there is not much code to be compatible with various browsers. Below is a good method for you to try it.
You need to make a js click to copy the current webpage url. The following method is used, but it can only be used normally in IE.
The method is as follows:
The Code is as follows:
Function copyURL (){
Var clipBoardContent = "";
ClipBoardContent + = document. title;
ClipBoardContent + = "";
ClipBoardContent + = this. location. href;
Window. clipboardData. setData ("Text", clipBoardContent );
Alert ("Copied successfully, paste it on your QQ/MSN and recommend it to your friends ");
}
------------------------- Separation line ---------------------------
Find a flash on the Internet
ZClip
ZClip
The zClip plugin is compatible with various browsers.
The method is simple. You only need to import a js file and a swf file.
The usage is as follows:
Import the required documents first:
The Code is as follows:
<Script type = "text/javascript" src = "js/jquery. js"> </script>
<Script type = "text/javascript" src = "js/jquery. zclip. js"> </script>
$ (Document). ready (function (){
$ ('A # copy-description'). zclip ({
Path: 'js/ZeroClipboard.swf ',
Copy: $ ('P # description'). text ()
});
// The link with ID "copy-description" will copy
// The text of the paragraph with ID "description"
$ ('A # copy-dynamic '). zclip ({
Path: 'js/ZeroClipboard.swf ',
Copy: function () {return $ ('input # dynamic '). val ();}
});
// The link with ID "copy-dynamic" will copy the current value
// Of a dynamically changing input with the ID "dynamic"
});