capture 'Paste' event in text-area

H

Henry

On Dec 9, 12:28 am, RJ wrote:

As mentioned, it is silly to even attempt to detect Ctrl+V. What
do you think that means outside of Windows? Also, what if the
paste (or whatever) operation is done through the edit menu?
<snip>

Even on Windows there are more keyboard pasting options than Ctrl+V,
i.e. Shift+Insert.
 
D

David Mark

On Dec 9, 5:35 am, David Mark wrote:> On Dec 9, 12:28 am, RJ wrote:



<snip>

Even on Windows there are more keyboard pasting options than Ctrl+V,
i.e. Shift+Insert.

Then there's the cut, delete, undo, redo, etc. commands.
 
M

maicon.littlefish

The scenario is.... there is a text-area that is used as chatbox where
user enters their text msgs for chatting ..now it has a fixed width
but the height increases according to the content.... now the problem
that i am facing is whenver i do a cntrl+v on to the textarea , the
height of the textarea does not increase according to the contents.
I tried capturing the cntrl key event using "event.ctrlKey" on
"onkeypress" event, but i works only for FF and fails in IE and
chrome.

Is there any way by which i can capture 'Paste' event......

Any help wld be highly appreciated.

Thanks,
RJ

Just set a html property "onpaste"..

some thing like this: <TEXTAREA name="comments" id="comments" rows="4"
cols="20" onpaste="false"></TEXTAREA>

Now anybody can paste anything in your text area!

if u wanna do it across javascript:

document.getElementsById("comments").onpaste = false

Sorry my poor english.. Im brazilian!!!
 
T

Thomas 'PointedEars' Lahn

RJ said:
[...] now the problem that i am facing is whenver i do a cntrl+v on to
the textarea , the height of the textarea does not increase according
to the contents. I tried capturing the cntrl key event using
"event.ctrlKey" on "onkeypress" event, but i works only for FF and
fails in IE and chrome.

Is there any way by which i can capture 'Paste' event......

Any help wld be highly appreciated. [...]

Just set a html property "onpaste"..

some thing like this: <TEXTAREA name="comments" id="comments" rows="4"
cols="20" onpaste="false"></TEXTAREA>
^^^^^^^^^^^^^^
That's proprietary nonsense.
Now anybody can paste anything in your text area!

You can have that without without invalid markup. Really. Maybe you meant
to say "Now _nobody_ can paste anything in your text area" but that is
equally wrong as this proprietary attribute would need to be supported.

And you completely missed the point of the OP's question. The goal is _not_
to cancel the paste operation, but to *capture* the corresponding event,
i.e. to recognize when it happened and handle it (resize the textarea).
if u wanna do it across javascript: ^
document.getElementsById("comments").onpaste = false

Nonsense. If anything, `onpaste' is the identifier of an event handler
property which expects either `null' or a reference to a callable (usually
Function) object. In order to prevent the default action for the event, one
would have to *return* `false':

document.getElementsById("comments").onpaste = function() {
return false;
};

Sorry my poor english.. Im brazilian!!!

You are also completely clueless; please refrain from giving further advice
until that changed. And as for your English: That's a lame excuse, you are
not even trying to use proper language to begin with. (And I can tell as
English is not my first language.)

That said, this is an *international* newsgroup so you could have written
in Portuguese as well. Not that it would have helped very much as to the
meaning of your posting, though.

Please trim your quotes when you post here next time.

<http://jibbering.com/faq/#posting>


PointedEars
 
R

Ron Merom

You may want to use FF's oninput event and IE's
onpropertychange event. I do not know, though, of a
solution for Safari/Chrome.
 
R

RJ

You may want to use FF's oninput event and IE's
onpropertychange event. I do not know, though, of a
solution for Safari/Chrome.

*** Sent via Developersdexhttp://www.developersdex.com***

Guys m sorry m posting in soo late.......
Setinterval method worked for me and it work across all browser , the
only problem i encountered was on IE .... the expansion of textarea
does not happen quickly.. it takes some time(although a fraction but
the lag is visible) to adjust to new height....

Guys, once again thanks for all ur replies
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top