0

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

  1. Save the above code to an HTML file
  2. Run it
  3. Use Ctrl + A, Ctrl + C
  4. It is alerting the whole html, including the page title, the javascripts etc.. in IE (see the attachedenter image description here image) but working fine in Chrome.

Can someone give me some hint on whats happening?

2
  • give ZeroClipboard a try, it makes copy for the clipboard really easy and no worries with crosss browser problems
    – balexandre
    Aug 18, 2013 at 20:28
  • It is NOT alerting the whole HTML. However, the selection does include the plain text content in the header - the content of the <title> and the <script> elements. Why it does that, no idea. But if you select the page by dragging with the mouse, it does select only the the content of the body.
    – Mr Lister
    Aug 19, 2013 at 8:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.