复制和粘贴的js代码 for IE/FireFox/mozilla/ns

2016-02-19 17:32 2 1 收藏

岁数大了,QQ也不闪了,微信也不响了,电话也不来了,但是图老师依旧坚持为大家推荐最精彩的内容,下面为大家精心准备的复制和粘贴的js代码 for IE/FireFox/mozilla/ns,希望大家看完后能赶快学习起来。

【 tulaoshi.com - Web开发 】

  Jscript有些属性其实挺好的,可惜就是只是IE支持,比如复制和粘贴的属性

  下面这段复制和粘贴的JAVASCRIPT的代码倒是可以支持IE/FireFox/mozilla/ns,,老外站点上看来的

  只是在firefox下需要修改一下about:config的一个属性

  

script language="javascript" type="text/javascript"!--function copy_clip(meintext){ if (window.clipboardData)  {   // the IE-manier  window.clipboardData.setData("Text", meintext);   // waarschijnlijk niet de beste manier om Moz/NS te detecteren;  // het is mij echter onbekend vanaf welke versie dit precies werkt:  }  else if (window.netscape)  {   // dit is belangrijk maar staat nergens duidelijk vermeld:  // you have to sign the code to enable this, or see notes below  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');   // maak een interface naar het clipboard  var clip = Components.classes['@mozilla.org/widget/clipboard;1']         .createInstance(Components.interfaces.nsIClipboard);  if (!clip) return;   // maak een transferable  var trans = Components.classes['@mozilla.org/widget/transferable;1']         .createInstance(Components.interfaces.nsITransferable);  if (!trans) return;   // specificeer wat voor soort data we op willen halen; text in dit geval  trans.addDataFlavor('text/unicode');   // om de data uit de transferable te halen hebben we 2 nieuwe objecten  // nodig om het in op te slaan  var str = new Object();  var len = new Object();   var str = Components.classes["@mozilla.org/supports-string;1"]        .createInstance(Components.interfaces.nsISupportsString);   var copytext=meintext;   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("Following info was copied to your clipboard:nn" + meintext);  return false;}//--/script

  notes about security:

  a cause of the tight security settings in mozilla you have to sign the javascript to make it work another way is to change your firefox/mozilla settings

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

  to do this add this line to your prefs.js file in your firefox/mozilla user profile directory

  user_pref("signed.applets.codebase_principal_support", true);

  or change it from within the browser with calling the "about:config" page

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

来源:https://www.tulaoshi.com/n/20160219/1615462.html

延伸阅读
标签: Web开发
titleJS复制本页地址/title input type="button"   name="Submit" onClick='copyToClipBoard()' value="点击复制本页地址,分享给QQ/MSN上的好友" width="100" height="16" script language="javascript" function copyToClipBoard(){ var clipBoardContent=&quo...
标签: Web开发
mozilla.org Base Styles * maintained by fantasai * (classes defined in the Markup Guide -http://mozilla.org/contribute/writing/markup) */ /* Suggested order: //显示属性 * display * list-style * position * float * clear //自身属性 * width * height * margin * padding * border * background //文本属性 * color * font * tex...
标签: word
Word2010中复制、剪切和粘贴技巧   其实在Word中编辑文档时(图老师整理),复制、剪切和粘贴可以说是最常使用的技巧。有关它们的技巧中,默认粘贴又是最难的,接下来,我们就来详细的了解一下吧。 第1步,打开Word2010文档窗口,依次单击文件→选项按钮,如图1所示。 ▲图1单击选项按钮 第2步,在打开的Word选项...
标签: Web开发
兼容IE与FF Code:间隔滚动效果-兼容IE和FireFox 14家国内银行启用CN新域名防诈骗华军,天空就暂停迅雷下载发布最新公告微软OneCare处子秀过关 拦住Word漏洞木马 [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
标签: 快捷键 电脑
快捷操作 首先简单介绍快捷操作的键位:剪切是 ctrl+x 复制是ctrl+c 粘贴是ctrl+v ,具体键位可以看后面的图。在有鼠标右键的情况下介绍这些是毫无意义的,下面介绍没有鼠标右键的情况下如何应用。 游戏复制方法 比如游戏的对话框,不支持直接复制,输入一段文字如何复制(该方法可以用于魔兽争霸局域网输入中文名)首先输入...

经验教程

167

收藏

44
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部