Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
javascript Copy to clip board from text area
Old 11-18-2011, 11:29 AM javascript Copy to clip board from text area
Junior Talker

Posts: 3
Name: Anes P.A
Trades: 0
Hi Friends,
I need a copy to clipboard functionality from a text area using javascript. I use Zclip for the purpose,
but it will not work as needed . I attach my working code along with this .. pls open index.html in browser
and try it . Do any one can pls give a javascript solution to copy textarea content to clipboard...

Thanks,
Anes
admod is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-18-2011, 11:48 AM Re: javascript Copy to clip board from text area
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Do any one can pls give a javascript solution to copy textarea content to clipboard..
There isn't one so you can't.

Or rather you can, but ONLY in Internet Explorer, browsers and javascript simply are not allowed that level of access to the machine they run on, for obvious reasons.

I've seen a few scripts that purport to work using a Flash function as a proxy, but they don't work reliably either.

I'm sure that the vast majority of users are familiar with Ctrl+A, Ctrl+C, Ctrl+V these days.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-18-2011, 03:27 PM Re: javascript Copy to clip board from text area
Extreme Talker

Posts: 246
Trades: 0
If you only need to worry about IE or have control over the browser people will be using (intranet site) you can use the following as an example:

Code:
<html>
<head>



</head>
<body>

Copy the text below and paste into textbox:
<br />
<br />
<br />

This is some text with 16 digit credit card number
<br />
1111-2222-3333-4444 this is one format
<br />
and this is another format 1111 2222 3333 4444
<br />
and this one 1111222233334444 is yet another format
<br />

<textarea id="txtPaste" style="width: 400px; height: 400px;"></textarea>

<script type="text/javascript">



	var txtPaste = document.getElementById('txtPaste');

	txtPaste.onbeforepaste = function(){
		return false;
	};

	txtPaste.onpaste = function(){
			var clipboard = window.clipboardData.getData('Text');

			window.clipboardData.setData('Text', clipboard.replace(/\b(\d{4})([ -]*?)(\d{4})([ -]*?)(\d{4})([ -]*?)(\d{4})\b/gi, '\$1xxxxxxxx\$7'));
	};
</script>

</body>
</html>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to javascript Copy to clip board from text area
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12168 seconds with 12 queries