JS Click to copy the text to the Paste Pad code Summary

Source: Internet
Author: User
Tags gettext

How to copy IE browser

Example 1

The code is as follows Copy Code

Text Copy
CopyText = function (str) {
if (Browerkernel.isie ()) {
Clipboarddata.setdata (' Text ', str);
Alert ("Site link has been copied to your Pasteboard" n you can use Ctrl + V paste);
}else{
Prompt ("Your browser does not support automatic replication, please press CTRL + C manually copy:", str);
}
};


Example 2


Click the Copy button code:

The code is as follows Copy Code

<script language=javascript>
<!--

function Mm_gotourl () {//v3.0
var i, args=mm_gotourl.arguments; Document. Mm_returnvalue = false;
For (i=0 i< (args.length-1); i+=2) eval (args[i]+ ". location= '" "+args[i+1]+" ");
}
function JM_CC (ob) {
var obj=mm_findobj (OB); if (obj) {
Obj.select (); Js=obj.createtextrange (); Js.execcommand ("Copy");}
}

function Mm_findobj (n, D) {//v4.0
var p,i,x; if (!d) d=document; if ((P=n.indexof ("?")) >0&&parent.frames.length) {
D=parent.frames[n.substring (p+1)].document; N=n.substring (0,p);}
if (!) ( X=d[n]) &&d.all) x=d.all[n]; for (i=0;! x&&i<d.forms.length;i++) X=d.forms[i][n];
for (i=0;! x&&d.layers&&i<d.layers.length;i++) X=mm_findobj (n,d.layers[i].document);
if (!x && document.getElementById) X=document.getelementbyid (n); return x;
}
-->
</SCRIPT>

<input Name=button onclick= "jm_cc (' Js_1 ')" Type=button value= copy to Clipboard >
<BR>
<form action= "" Method=post name=form1>
<div align= "center" >
<textarea cols=70 name=js_1 rows=10 wrap=virtual> content to replicate </textarea>
</div>
</form>

Example 3

The code is as follows Copy Code

(function () {
window[' Util '] = {
cache:{},
Gettext:function () {
return Util.CACHE.CLIPBOARD_TEXT;
},
Successhide:function () {
Alert ("Copy the North Sea 365 network recruitment email address!");
},
Copy:function (Pstr,hasreturn, ISDO) {
var html = [];
Html.push (' <object type= ' Application/x-shockwave-flash "Data=" clipboard.swf?gettext=util.gettext&success= Util.successhide "width=" "height=" "style=" position:relative;top:11px;left:-50px; "id=" ff_clipboard_swf ">" );
Html.push (' <param name= "quality" value= "High"/> ");
Html.push (' <param name= "allowscriptaccess" value= "Samedomain"/> ");
Html.push (' <param name= "allowfullscreen" value= "true"/> ");
Html.push (' <param name= "wmode" value= "Transparent"/> ");
Html.push (' </object> ');
var Yu=document.getelementbyid (' Copy '). InnerHTML;
document.getElementById (' Copy '). Innerhtml=yu+html.join (');
Util.CACHE.CLIPBOARD_TEXT = pstr;
}
}
Util.copy (' zhaopin@beihai365.com ');
})();


If you want to be compatible with IE. You also have to add
Copy code code as follows:
if (window.clipboarddata) {
Window.clipboardData.setData ("Text", pstr);
Util.successhide ();
}

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.