Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: copy browser selection to clibboard


Message #1 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Mon, 19 Nov 2001 17:10:03 -0000
document.execCommand("Copy");

Regards

Joe Fawcett



>From: "Alex Shiell, ITS, EC, SE" <alex.shiell@s...>
>Reply-To: "javascript" <javascript@p...>
>To: "javascript" <javascript@p...>
>Subject: [javascript] copy browser selection to clibboard
>Date: Mon, 19 Nov 2001 17:10:03 -0000
>
>I can select the contents of my page with this code:
>
>var r = document.body.createTextRange();
>r.findText(document.body.innerText);
>r.select();
>
>but now how can I copy it?
>
>The only thing I can find is
>
>window.clipboardData.setData("Text",document.body.innerHTML);
>
>but this displays strange behaviour in that it only seems to work if the
>user hasn't manually copied anything from the page.  Also a manual copy and
>paste (which I am trying to emulate) preservers formatting nicely, which 
>the
>above method doesn't.
>
>________________________________________________________________________
>Scottish Enterprise Network
>http://www.scottish-enterprise.com
>
>Headquarters Address & Contact Numbers
>
>150 Broomielaw
>5 Atlantic Quay
>Glasgow
>G2 8LU.
>Tel:  +44 (0) 141 248 2700.
>Fax:  +44 (0)141 221 3217
>
>  This message is sent in confidence for the addressee only.
>It may contain legally privileged information. The contents are not to
>be disclosed to anyone other than the addressee. Unauthorised recipients
>are requested to preserve this confidentiality and to advise the sender
>immediately of any error in transmission.
>
>
>
>
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


  Return to Index