复制和粘贴的js代码(IE/FireFox/mozilla/ns)
2010-05-08 21:30
603 查看
Jscript有些属性其实挺好的,可惜就是只是IE支持,比如复制和粘贴的属性
下面这段复制和粘贴的JAVASCRIPT的代码倒是可以支持IE/FireFox/mozilla/ns,,老外站点上看来的
只是在firefox下需要修改一下about:config的一个属性
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
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
下面这段复制和粘贴的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:\n\n" + 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
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
相关文章推荐
- 复制到剪贴板的js代码(兼容ie、firefox、chorme、safari...什么都兼容!)
- 兼容IE与Firefox的js 复制代码
- js 复制功能 支持 for IE/FireFox/mozilla/ns
- js 复制代码 适用于firfox IE Mozilla Opera 保证成功
- 复制到剪贴板的js代码(兼容ie、firefox、chorme、safari...什么都兼容!)
- 兼容IE与Firefox的js 复制代码
- js 复制功能 支持 for IE/FireFox/mozilla/ns
- 复制到剪贴板的js代码(兼容ie、firefox、chorme、safari...什么都兼容!)
- 兼容IE与Firefox的js 复制代码
- 随机显示个性签名的js代码(兼容ie,firefox)
- 网站内容禁止复制和粘贴、另存为的js代码
- IE,firefox(火狐)浏览器无提示关闭窗口js实现代码小结
- JS实时显示当前时间(IE+firefox)浏览器兼容代码(图证)
- 统一接口:为FireFox添加IE的方法和属性的js代码
- 复制Input内容的js代码_支持所有浏览器,修正了Firefox3.5以上的问题
- js上传图片预览功能代码,兼容IE,FireFox,Chrome浏览器
- 兼容ie和火狐firefox的js调用flash播放器代码特效
- 兼容IE和fireFox的设为首页、加入收藏JS代码
- JS+flash实现复制功能(兼容IE和firefox)
- extjs中的JS代码在firefox可以正常运行,在IE中无法运行的方法。