我正在为一个新项目处理剪贴板数据。我在 IE 10(版本 10.0.9200.16660)中遇到了一个奇怪的问题
以下是我的代码
<!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>
错误
- 将上述代码保存到 HTML 文件中
- 运行
- 使用 Ctrl + A、Ctrl + C
- 它在 IE 中提醒整个 html,包括页面标题、javascripts 等(请参见附图
),但在 Chrome 中工作正常。
有人可以给我一些提示吗?