首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

, 小弟我这段代码只有在IE下正常,其它全部不行

2013-08-10 
求助, 我这段代码只有在IE下正常,其它全部不行,script languagejavascriptvar lang new Array() v

求助, 我这段代码只有在IE下正常,其它全部不行,


<script language="javascript">
var lang = new Array();
 var userAgent = navigator.userAgent.toLowerCase();
  var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
   var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
    var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf ('msie') + 5, 3);
function Pasteit()
{
var p=document.getElementById("Paste").value=window.clipboardData.getData("text",p);
}
function copycode(obj) { 
if(is_ie && obj.style.display != 'none') {
 var rng = document.body.createTextRange();
  rng.moveToElementText(obj); 
  rng.scrollIntoView(); 
  rng.select(); 
  rng.execCommand("Copy"); 
  rng.collapse(false);
  alert('已复制到剪贴板!'); 
  } 
  }
</script>



<textarea id="Paste" name="LyricsWord" cols="90" rows="20" wrap="off" style="overflow-x:scroll; overflow-y:hidden;"></textarea>
<input type="button" value="点击复制" onclick="copycode(document.all.Paste);">

[解决办法]
引用:
Quote: 引用:

为兼容其它,好像都是通过flash实现的


那我这段代码是通过flash实现可以复制了,就是点了复制后没有任何提示,不知道如何能加上"已复制到剪贴板!"这几个字,

<script type="text/javascript" src="ZeroClipboard.js"></script>
<script language="JavaScript">
var clip = null;

function $(id) { return document.getElementById(id); }

function init() {
clip = new ZeroClipboard.Client();
clip.setHandCursor( true );


clip.addEventListener('load', function (client) {
debugstr("Flash movie loaded and ready.");
});

clip.addEventListener('mouseOver', function (client) {
// update the text on mouse over
clip.setText( $('fe_text').value );
});

clip.addEventListener('complete', function (client, text) {
debugstr("Copied text to clipboard: " + text );
});

clip.glue( 'd_clip_button', 'd_clip_container' );
}

function debugstr(msg) {
var p = document.createElement('p');
p.innerHTML = msg;
$('d_debug').appendChild(p);
                        }

</script>



红色的这段可以修改成提示, 





你把这句
debugstr("Copied text to clipboard: " + text ); 
改成
alert('已复制到剪贴板!');

把下面的你说要改的删除就行了,你式式

热点排行