Javascript 使用Ctrl+;复制所有剪贴板数据时出错;web浏览器中的一个应用程序
我正在为一个新项目处理剪贴板数据。我在IE 10(版本10.0.9200.16660)中遇到了一个奇怪的问题 下面是我的代码Javascript 使用Ctrl+;复制所有剪贴板数据时出错;web浏览器中的一个应用程序,javascript,jquery,html,internet-explorer,Javascript,Jquery,Html,Internet Explorer,我正在为一个新项目处理剪贴板数据。我在IE 10(版本10.0.9200.16660)中遇到了一个奇怪的问题 下面是我的代码 <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>page - title</ti
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>page - title</title>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
jQuery(document).on('copy', function(e){
var body_element, selection, pageLink, copytext, newdiv, url;
url = document.location.href;
body_element = document.getElementsByTagName('body')[0];
selection = window.getSelection();
alert(selection);
});
</script>
</head>
<body>
<ol>
<li>Hi</li>
<li>Hi</li>
<li>Hi</li>
<li>Hi</li>
<li>Hi</li>
</ol>
</body>
</html>
页码-标题
jQuery(document).on('copy',函数(e){
变量body_元素,selection,pageLink,copytext,newdiv,url;
url=document.location.href;
body_element=document.getElementsByTagName('body')[0];
selection=window.getSelection();
警报(选择);
});
你好
你好
你好
你好
你好
错误
有人能告诉我发生了什么事吗?试试看,它使剪贴板的复制变得非常容易,而且不用担心交叉浏览器问题。它不会提醒整个HTML。但是,选择内容确实包括标题中的纯文本内容—
和
元素的内容。为什么会这样,不知道。但是,如果您使用鼠标拖动来选择页面,它将只选择正文的内容。