Forum Moderators: open

Message Too Old, No Replies

Copying a text on webpage(instead of using Edit->Copy)

Copying a text on webpage

         

jj_box

2:11 pm on Sep 14, 2004 (gmt 0)

10+ Year Member



Is there a way to copy a text such as a link by using some form of input tag instead of using Edit->Copy feature from the browser?

For example:

A webpage that looks like this:
===========
Copy the link below to your emails:
http ://www.example.com/user=abc
===========

I want to be able to use some sort of a feature that would highlight that link above and copy - this feature is for a very novice user.

Thanks,

[edited by: BlobFisk at 2:32 pm (utc) on Sep. 14, 2004]
[edit reason] Examplified URL [/edit]

freethink

2:18 pm on Sep 14, 2004 (gmt 0)

10+ Year Member



[javascript.internet.com...]

or something similar - the above will copy selected text

chrisnrae

2:33 pm on Sep 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can highlight the text and click control+C and it will copy the text. I'm not sure if this is what you mean - I'm assuming you are using windows and are trying to figure out the Windows Keyboard Shortcuts for XP [support.microsoft.com] or other versions of Windows [support.microsoft.com].

jj_box

3:33 pm on Sep 14, 2004 (gmt 0)

10+ Year Member



Thanks Freethink and Chrisnrae.

What I want to do is, find a way of highlighting a sample text like the link and 'paste it to clipboard' by let say pressing a 'copy' button.

I need this feature to help out my fellow colleagues who very new to internet and such.

They are not familiar with Control-C, or using Right-click the mouse button and such.

Thanks again for your inputs...

Reflection

4:02 pm on Sep 14, 2004 (gmt 0)

10+ Year Member



I need this feature to help out my fellow colleagues who very new to internet and such.

They are not familiar with Control-C, or using Right-click the mouse button and such.


Well they may as well start learning now. As they say, it's not rocket science.

freethink

4:18 pm on Sep 14, 2004 (gmt 0)

10+ Year Member



<script language="javascript">
function cpy(value){
bResult = window.clipboardData.setData("Text",value);
}
</script>

<a href="http://www.example.com/user=abc" onClick="cpy(this.href);return false;">Click here to copy link</a>


You might want to call an alert box when the copy actually happens so they know it's been successfull.

I agree with with everyone that copying isn't rocket science and if your users can paste why can't they copy?

[edited by: freethink at 5:02 pm (utc) on Sep. 14, 2004]

jj_box

4:27 pm on Sep 14, 2004 (gmt 0)

10+ Year Member



I wish I could say that to them and my supervisor!

I did find a solution from vigourous web searches, and it got to do with using the .execCommand('Copy') and hidden input tag, and using some javascript cmds. :)

Thanks again for all of your times!

TheDoctor

8:00 am on Sep 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Would you like to share with us what the solution actually is? This will help others who find themselves in the same situation as you.

upside

8:39 am on Sep 15, 2004 (gmt 0)

10+ Year Member



Just for the record...the cpy() function does work on any Macintosh browser that I've tried. A truly cross-platform solution is to provide instructions on how to copy which are tailored to their particular OS.