亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jQuery簡單實(shí)現(xiàn)點(diǎn)擊文本框復(fù)制內(nèi)容到剪貼板上的方法

 更新時間:2016年08月01日 11:16:31   作者:Quber  
這篇文章主要介紹了jQuery簡單實(shí)現(xiàn)點(diǎn)擊文本框復(fù)制內(nèi)容到剪貼板上的方法,涉及jQuery針對瀏覽器的判定與剪貼板的讀寫操作技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery簡單實(shí)現(xiàn)點(diǎn)擊文本框復(fù)制內(nèi)容到剪貼板上的方法。分享給大家供大家參考,具體如下:

//點(diǎn)擊文本框復(fù)制其內(nèi)容到剪貼板上方法
function copyToClipboard(txt) {
  if (window.clipboardData) {
    window.clipboardData.clearData();
    window.clipboardData.setData("Text", txt);
    alert("已經(jīng)成功復(fù)制到剪帖板上!");
  } else if (navigator.userAgent.indexOf("Opera") != -1) {
    window.location = txt;
  } else if (window.netscape) {
    try {
      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    } catch (e) {
      alert("被瀏覽器拒絕!\n請在瀏覽器地址欄輸入'about:config'并回車\n然后將'signed.applets.codebase_principal_support'設(shè)置為'true'");
    }
    var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
    if (!clip) return;
    var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
    if (!trans) return;
    trans.addDataFlavor('text/unicode');
    var str = new Object();
    var len = new Object();
    var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
    var copytext = txt;
    str.data = copytext;
    trans.setTransferData("text/unicode", str, copytext.length * 2);
    var clipid = Components.interfaces.nsIClipboard;
    if (!clip) return false;
    clip.setData(trans, null, clipid.kGlobalClipboard);
    alert("已經(jīng)成功復(fù)制到剪帖板上!");
  }
}
//點(diǎn)擊文本框復(fù)制其內(nèi)容到剪貼板上
function setCopyLink() {
  $("#txt_CopyLink").val(document.URL)
  .focus(function () {
    $(this).css({ "background-color": "#ddd" }).select();
    copyToClipboard($("#txt_CopyLink").val());
  }).blur(function () {
    $(this).css({ "background-color": "#fff" });
  });
}

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常見事件用法與技巧總結(jié)》、《jQuery form操作技巧匯總》、《jQuery常用插件及用法總結(jié)》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論