Sunday, 18 August 2013

Error with clipboard data when copying all using Ctrl+A in web browser

Error with clipboard data when copying all using Ctrl+A in web browser

I am working with clipboard data processing for a new project. I am facing
a strange problem in IE 10 (Version 10.0.9200.16660)
Following is my code
<!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>
Error
Save the above code to an HTML file
Run it
Use Ctrl + A, Ctrl + C
It is alerting the whole html, including the page title, the javascripts
etc.. in IE (see the attached image) but working fine in Chrome.
Can someone give me some hint on whats happening?

No comments:

Post a Comment