...

View Full Version : Select all and copy not working help!



Jonathanrw
04-26-2008, 07:53 PM
I am trying to get it where when you click in the text box it will select all the text and copy it to the clipboard but it only selects the text but does not copy it. Am I missing something or is part of my code wrong.

Look below at code.
Please help. Thanks!

<html>
<body>
<script type="text/javascript">
function SelectAll(id)
{
document.getElementById(id).focus();
document.getElementById(id).select();
}
</script>


<input type="text" id="direct-url17" onclick="SelectAll('direct-url17');" value="Text which I am trying to get copied." size="38" onclick="highlight(getElementById('direct-url')); APITrack('copy_details_url');" title="Click to Copy" name="T14"/><font color="#FF0000" size="2"><u>Click in box to copy.<br></u></font>



</body>
</html>

Philip M
04-26-2008, 07:58 PM
<span id="copytext" style="height:120;width:200;background-color:teal">
This text will be copied onto the clipboard when you click the button below.
</span>

<textarea id="holdtext" style ="display:none;"></textarea>
<br><br>
<input type = "button" onClick="ClipBoard();" value = "Copy to Clipboard"</button>

<script type = "text/javascript">

function ClipBoard() {
holdtext.innerText = copytext.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("RemoveFormat");
Copied.execCommand("Copy");
window.status="Contents copied to clipboard"
setTimeout("window.status=''",2500)
}

</script>

A1ien51
04-27-2008, 04:36 AM
FYI: Browsers have a setting to disable copying and reading values from the clipboard.

Eric

Philip M
04-27-2008, 07:49 AM
FYI: Browsers have a setting to disable copying and reading values from the clipboard.

Eric

I don't find this in IE6. Could you direct me to the appropriate setting?

A1ien51
04-27-2008, 03:11 PM
IE started it in IE7 since reading and writing to the clipboard can be a security risk for those that copy sensitive material to the clipboard.

Eric

Philip M
04-27-2008, 03:28 PM
Thanks for the info. As I see it this security feature is included in IE7 only and prevents programmatic reading from the clipboard, as opposed to writing or copying to it.

The default option is Prompt, but the feature can be completely disabled, or the user can choose to allow programmatic clipboard access to internet trusted zones only.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum