Access browser menu (copy/paste) from Javascript

B

Bani

Is it possible to get browser-menu events (IE) into Javascript?

I have a special copy/paste on the onkeydown event (ctrl+c/ctrl+v). Now
the users would like to trigger it also from the browser menu.
 
M

Matt Kruse

Bani said:
I have a special copy/paste on the onkeydown event (ctrl+c/ctrl+v).
Now the users would like to trigger it also from the browser menu.

<body onCopy="myfunc()" onPaste="myfunc2()">
 
M

McKirahan

Bani said:
Is it possible to get browser-menu events (IE) into Javascript?

I have a special copy/paste on the onkeydown event (ctrl+c/ctrl+v). Now
the users would like to trigger it also from the browser menu.

What do you mean by "browser menu"?

Browsers have Cut, Copy, and Paste functions under "Edit" on the Menu Bar.

Or do you mean the right-click context menu?
 
B

Bani

I haven't seen this two event-handlers in my documentation. But it
works!

Thank you.

Does it work also for other browsers then IE?
 
M

McKirahan

Bani said:
I haven't seen this two event-handlers in my documentation. But it
works!

Thank you.

Does it work also for other browsers then IE?

It works for me under FF and NS6.2.
 
C

Csaba Gabor

Are you sure about that? onPaste has been logged as a Mozilla bug
at https://bugzilla.mozilla.org/show_bug.cgi?id=280683
(you can, however, mostly monitor a textbox/textarea for change in
FF though the buggy method at
https://bugzilla.mozilla.org/show_bug.cgi?id=285272)

Also, I just tried the snippet below in my Firefox 1.0.1+ and got
no alert boxes vs both alert firing for IE 6 (on my Win XP Pro).


<body onpaste="alert('Body paste')">
<form name=mine method=get action=''>
<input name=tbtest onpaste="alert('Input paste')">
</form>
</body>

Csaba Gabor from Vienna
 
M

McKirahan

Csaba Gabor said:
Are you sure about that? onPaste has been logged as a Mozilla bug
at https://bugzilla.mozilla.org/show_bug.cgi?id=280683
(you can, however, mostly monitor a textbox/textarea for change in
FF though the buggy method at
https://bugzilla.mozilla.org/show_bug.cgi?id=285272)

Also, I just tried the snippet below in my Firefox 1.0.1+ and got
no alert boxes vs both alert firing for IE 6 (on my Win XP Pro).


<body onpaste="alert('Body paste')">
<form name=mine method=get action=''>
<input name=tbtest onpaste="alert('Input paste')">
</form>
</body>

Csaba Gabor from Vienna

Here's what I used to test:

<html>
<head>
<title>CopyPaste.htm</title>
<script type="text/javascript">
function myCopy() {
alert("Copy");
}
function myPaste() {
alert("Paste");
}
</script>
</head>
<body onCopy="myCopy()" onPaste="myPaste()">
<form>
<textarea cols="50" rows="10">Hello World</textarea>
</form>
</body>
</html>
 
T

Thomas 'PointedEars' Lahn

McKirahan said:
It works for me under FF and NS6.2.

However, it is not Valid HTML and as such not supposed to work generally.
Relying on it is risky at best.


PointedEars°
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top