Is this possible with Javascript in anyway? :) 13 31878
On Dec 2, 6:47 am, halbe...@gmail.com wrote:
Is this possible with Javascript in anyway? :)
Yes, it is possible to detect a paste action.
Here's a simple exemple, preventing to paste in a textarea :
<html>
<head>
<script>
window.addEventListener('load', function (e)
{
document.getElementById('text').addEventListener(' keydown', function
(e)
{
if (e.keyCode == 86) //86 is Paste event
{
alert('You may not paste here !');
e.preventDefault();
}
document.getElementById('events').innerHTML += e.keyCode + ' ' +
e.which + '<br />';
}, false);
}, false);
</script>
</head>
<body>
<textarea id="text">
</textarea>
<div id="events">
</div>
</body>
</html> dr*********@gmail.com a écrit :
On Dec 2, 6:47 am, halbe...@gmail.com wrote:
>Is this possible with Javascript in anyway? :)
Yes, it is possible to detect a paste action.
Here's a simple exemple, preventing to paste in a textarea :
How do you expect to tape 'v' ? or 'V' ?
Anyway,
that doesn't work at all !
report under textbox tells me : 224 224
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
On Dec 2, 1:18 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
dracogni...@gmail.com a écrit :
On Dec 2, 6:47 am, halbe...@gmail.com wrote:
Is this possible with Javascript in anyway? :)
Yes, it is possible to detect a paste action.
Here's a simple exemple, preventing to paste in a textarea :How do you expect to tape 'v' ? or 'V' ?
Anyway,
that doesn't work at all !
report under textbox tells me : 224 224
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Oups... You're totally rights... >_<
I'm sorry i wasn't careful enough about that...
I'm going to see if I can do something about it :p
P.S. Ton mac est si vieux ?
--
Naixn.
On Dec 2, 1:30 pm, "dracogni...@gmail.com" <dracogni...@gmail.com>
wrote:
On Dec 2, 1:18 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
dracogni...@gmail.com a écrit :
On Dec 2, 6:47 am, halbe...@gmail.com wrote:
>Is this possible with Javascript in anyway? :)
Yes, it is possible to detect a paste action.
Here's a simple exemple, preventing to paste in a textarea :How do you expect to tape 'v' ? or 'V' ?
Anyway,
that doesn't work at all !
report under textbox tells me : 224 224
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of dateOups... You're totally rights... >_<
I'm sorry i wasn't careful enough about that...
I'm going to see if I can do something about it :p
P.S. Ton mac est si vieux ?
--
Naixn.
<script>
window.addEventListener('load', function (e)
{
document.getElementById('text').addEventListener(' keydown', function
(e)
{
if (e.keyCode == 86 && e.ctrlKey) //86 is 'v' char key
{
e.preventDefault();
}
document.getElementById('events').innerHTML += e.keyCode + ' ' +
e.which + '<br />';
}, false);
}, false);
</script>
Here it is.
I forgot to put the "e.ctrlKey" check ( to check wether control key was
pressed, or not.
Thing is I don't have any way to try javascript on Safari ( as there's
no JavaScriptCore port on Linux, apart from KHTML, which begins to
differs a lot from WebCore... ).
What is 224 ? Ctrl+V keycode, or V keycode ?
Is the e.ctrlKey working with safari ? Since I know you have to "pomme
+ v" to paste ( sorry I don't remember the english equivalent for
'pomme' [ I just know it's not " Apple " :p ] ).
--
Naixn. dr*********@gmail.com a écrit :
On Dec 2, 1:18 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
>that doesn't work at all !
Oups... You're totally rights... >_<
I'm going to see if I can do something about it :p
P.S. Ton mac est si vieux ?
The so noisy G4 MDD (1,25Mhz OS 10.3.9) 2 years old.
P.S. : qu'est-ce qu'il a le Messenger de ton Mozilla ?
(pour ne pas gommer la signature de l'envoyeur dans les réponses)
--
Stephane Moriaux et son moins vieux Mac déjà dépassé
Stephane Moriaux and his less old Mac already out of date
ASM wrote :
dr*********@gmail.com a écrit :
>On Dec 2, 1:18 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid> wrote:
>>that doesn't work at all !
>Oups... You're totally rights... >_< I'm going to see if I can do something about it :p
>P.S. Ton mac est si vieux ?
The so noisy G4 MDD (1,25Mhz OS 10.3.9) 2 years old.
P.S. : qu'est-ce qu'il a le Messenger de ton Mozilla ?
(pour ne pas gommer la signature de l'envoyeur dans les réponses)
In fact, it's an old one!
Please refer to my previous post to check the changes I made.
Maybe you'll also be able to answer my safari-specific questions :)
P.S. : Tout simplement que j'utilisais google newsgroups.
C'est maintenant corrigé :)
--
Naixn http://fma-fr.net dr*********@gmail.com a écrit :
>
Here it is.
I forgot to put the "e.ctrlKey" check ( to check wether control key was
pressed, or not.
On Mac Control key is not used to copy/paste/etc
we use touch Command (Pomme).
With FireFox, with Command + v and Command + z
keyCode returns 224
Command associated with others touchs (x, a, p, ... ) keyCode returns
correspondant character/touch key code.
Thing is I don't have any way to try javascript on Safari
My tests show Safari doesn't report touch Command (Pomme - Apple)
nor keyCode as if anything was pressed.
My test with Opera : Opera doesn't give a special code for
Command+v Command+c (normal letter key code)
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
ASM wrote :
dr*********@gmail.com a écrit :
>> Here it is. I forgot to put the "e.ctrlKey" check ( to check wether control key was pressed, or not.
On Mac Control key is not used to copy/paste/etc
we use touch Command (Pomme).
With FireFox, with Command + v and Command + z
keyCode returns 224
Command associated with others touchs (x, a, p, ... ) keyCode returns
correspondant character/touch key code.
>Thing is I don't have any way to try javascript on Safari
My tests show Safari doesn't report touch Command (Pomme - Apple)
nor keyCode as if anything was pressed.
My test with Opera : Opera doesn't give a special code for
Command+v Command+c (normal letter key code)
Well, let's correct it :
<script>
window.addEventListener('load', function (e)
{
document.getElementById('text').addEventListener(' keydown', function
(e)
{
if ((e.keyCode == 86 && e.ctrlKey) || (e.keyCode == 224 && e.metaKey)
{
e.preventDefault();
}
document.getElementById('events').innerHTML += e.keyCode + ' ' +
e.which + '<br />';
}, false);
}, false);
</script>
Ok now, how does it work with you, with this correction ? :)
--
Naixn http://fma-fr.net ha******@gmail.com wrote:
Is this possible with Javascript in anyway? :)
IE/Win has events for that:
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onbeforepaste.asp>
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onpaste.asp>
Mozilla has the input event/oninput event handler that fires for any
kind of input, including a paste operation.
--
Martin Honnen http://JavaScript.FAQTs.com/ dr*********@gmail.com said the following on 12/2/2006 6:09 AM:
On Dec 2, 6:47 am, halbe...@gmail.com wrote:
>Is this possible with Javascript in anyway? :)
Yes, it is possible to detect a paste action.
Here's a simple exemple, preventing to paste in a textarea :
No it doesn't. Open your test page, put the cursor in the textarea, and
press the key combination of <Shift><Insert>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote :
dr*********@gmail.com said the following on 12/2/2006 6:09 AM:
>On Dec 2, 6:47 am, halbe...@gmail.com wrote:
>>Is this possible with Javascript in anyway? :)
Yes, it is possible to detect a paste action. Here's a simple exemple, preventing to paste in a textarea :
No it doesn't. Open your test page, put the cursor in the textarea, and
press the key combination of <Shift><Insert>
In fact... too bad there's no onPaste event ( apart from IE I mean ).
Plus, right-click and paste doesn't work either.
I don't know, then, how to prevent/handle paste in (Gecko/Presto/Webcore)-based
browsers?
--
Naixn http://fma-fr.net
<html>
<head>
<script>
window.addEventListener('load', function (e)
{
document.getElementById('text').addEventListener(' keydown', function
(e)
{
if (e.keyCode == 86) //86 is Paste event
{
alert('You may not paste here !');
e.preventDefault();
}
document.getElementById('events').innerHTML += e.keyCode + ' ' +
e.which + '<br />';
}, false);
}, false);
</script>
</head>
<body>
<textarea id="text">
</textarea>
<div id="events">
</div>
</body>
</html>
When I cut-and-paste this and run on IE, I get a 'object does not
support this property or metod'. Is something getting cut-off in my
code above? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ringwraith |
last post by:
Hello!
How to detect in Python that some click action was performed in some module
imported by my main module?
Let's assume I have a tree.py module that implements all functionality of a
tree...
|
by: Radovan Radic |
last post by:
Hello all,
I am new to .NET and a i am moving from Delphi (finally!) to C#.
Now, i am trying to develop custom TextBox for numeric input. I have done it
almost, now i need to prevent paste so...
|
by: Andrés OrtÃz |
last post by:
Hi
I need that my TextBox don't work for copy-paste (Ctrl+C) and other forms
that we used for copy text.
Thanks
|
by: Steve |
last post by:
Hi all,
Is it possible to disable pasting from the clipboard into a textbox ?? I
can't find a property for it but I guess it must be possible.
thanks
Steve
|
by: Rich |
last post by:
Hello,
I need to trap/detect when a textbox is entered via the tabkey. If the
textbox is not empty when entered via the tabkey then set focus to next
textbox. To enter that textbox would then...
|
by: Julian |
last post by:
Hi
In VB .Net how do you prevent characters apart from numbers being pasted
into a text box?
Julian
|
by: Dan Sikorsky |
last post by:
How can we tell if the value in a FormView EditItemTemplate TextBox has
changed from its initial value so that we know if we have to update the
corresponding db table column value?
--
Thank you...
|
by: Steve |
last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user
clicks on a toolbar button, the cut/copy/paste will work with whatever
textbox the cursor is current located in (I have...
|
by: sid |
last post by:
Can someone tell me how to detect "Action Cancelled" page with out
polling.
I have a frame set and I want to make sure the other frame is
displaying what it is supposed to without polling. For...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |