473,750 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mimicing the Copy Command with Javascript

Hi!

I have perhaps a strange question... I have a javascript that
activates on a right click and shows the user a little menu of links.
However, by doing so, it disables the users ability to use the Copy
Command when doing a normal right click. I know that in some cases
this would be good for someone who wants to make it harder to copy
pictures from their site... but in this case I WANT people to be able
to copy the pictures....

Is there any way that I can replicate the normal Copy Command in
Javascript so I can add that as an item on the menu? The menu already
gets the x,y coordinates of the mouse click if that helps..

Any ideas?

Thanks!

-Sarah.


Jul 20 '05 #1
9 3033

"Sarah" <no***********@ zhouse.com> wrote in message
news:1s******** *************** *********@4ax.c om...
Hi!

I have perhaps a strange question... I have a javascript that
activates on a right click and shows the user a little menu of links.
However, by doing so, it disables the users ability to use the Copy
Command when doing a normal right click. I know that in some cases
this would be good for someone who wants to make it harder to copy
pictures from their site... but in this case I WANT people to be able
to copy the pictures....

Is there any way that I can replicate the normal Copy Command in
Javascript so I can add that as an item on the menu? The menu already
gets the x,y coordinates of the mouse click if that helps..


It's easy... DON'T MESS WITH MY RIGHT CLICK!
Jul 20 '05 #2
On Thu, 04 Mar 2004 04:57:43 GMT, "Seeker" <do*******@me.h ere> wrote:

"Sarah" <no***********@ zhouse.com> wrote in message
news:1s******* *************** **********@4ax. com...
Hi!

I have perhaps a strange question... I have a javascript that
activates on a right click and shows the user a little menu of links.
However, by doing so, it disables the users ability to use the Copy
Command when doing a normal right click. I know that in some cases
this would be good for someone who wants to make it harder to copy
pictures from their site... but in this case I WANT people to be able
to copy the pictures....

Is there any way that I can replicate the normal Copy Command in
Javascript so I can add that as an item on the menu? The menu already
gets the x,y coordinates of the mouse click if that helps..


It's easy... DON'T MESS WITH MY RIGHT CLICK!

Thank you... that's very helpful...
Jul 20 '05 #3
On Thu, 04 Mar 2004 04:49:48 GMT, Sarah <no***********@ zhouse.com> wrote:

[snip]
Is there any way that I can replicate the normal Copy Command in
Javascript so I can add that as an item on the menu? The menu already
gets the x,y coordinates of the mouse click if that helps..


[snip]

There is no standard way. That is, no way that will work on all browsers.
If a solution is available, it is specific to a subset of browsers, and I
don't know it. I couldn't even find a way with IE, so I doubt it's
possible.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4

"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:op******** ******@news-text.blueyonder .co.uk...
On Thu, 04 Mar 2004 04:49:48 GMT, Sarah <no***********@ zhouse.com> wrote:

[snip]
Is there any way that I can replicate the normal Copy Command in
Javascript so I can add that as an item on the menu? The menu already
gets the x,y coordinates of the mouse click if that helps..


[snip]

There is no standard way. That is, no way that will work on all browsers.
If a solution is available, it is specific to a subset of browsers, and I
don't know it. I couldn't even find a way with IE, so I doubt it's
possible.

This has been discussed here a number of times before.

The general consensus is that you can not replicate many of the functions
provided in the context menu so don't mess with it. Leave it right alone.

Provide the functionality elsewhere.

Cheers
Richard.
Jul 20 '05 #5
On Thu, 04 Mar 2004 12:21:56 GMT, Richard Formby <rf***@cueword. com.au>
wrote:
"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:op******** ******@news-text.blueyonder .co.uk...
[mimicking context menu functionality]
There is no standard way. That is, no way that will work on all
browsers. If a solution is available, it is specific to a subset
of browsers, and I don't know it. I couldn't even find a way with
IE, so I doubt it's possible.


This has been discussed here a number of times before.


I know. I think I even commented at the last occasion.
The general consensus is that you can not replicate many of the functions
provided in the context menu so don't mess with it. Leave it right alone.


And I whole-heartedly agree. However, the OP was already given that
opinion, though more tersely, and didn't like it. I thought that I'd make
a more definite point.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #6
Ivo
People wrote:
[mimicking context menu functionality]
There is no standard way. That is, no way that will work on all
browsers. If a solution is available, it is specific to a subset
of browsers, and I don't know it. I couldn't even find a way with
IE, so I doubt it's possible.


The general consensus is that you can not replicate many of the functions provided in the context menu so don't mess with it. Leave it right

alone.

In IE you can write to the clipboard using
somevariable.ex ecCommand("Copy ");

A compromise on contextmenus, allowing authors to customize it for their
purpose as well as leave the default contextmenu inplace for everyone else,
is to check whether the menu is currently visible when a right-click occurs,
and if so, display the other contextmenu. A (bit old by now) approach that
combines the contxtmenu with whatever may have been scripted, can be found
at <URL: http://4umi.com/web/javascript/contextmenu.htm >. Rightclick once
and you get some silly options, rightclick again and you get the default
menu!
HTH
Ivo
Jul 20 '05 #7
Ivo wrote:
<snip>
In IE you can write to the clipboard using
somevariable.ex ecCommand("Copy ");
Are you proposing that individual elements have execCommand methods in
IE? They don't, execCommand is a method of document, controlRange and
TextRange implying a need to make/generate a selection/Range prior to
attempting to save it to the clipboard..

(There is also a whole procedure for examining browser support for any
particular execCommand operation:- queryCommandSup ported,
queryCommandEna bled.)

<snip> ... . Rightclick once and you get some silly options,
rightclick again and you get the default menu!


Or you get nothing, or just the original context menu, depending on the
browser. Supplementary context menus are just not achievable
cross-browser, which is why the best advice is to leave them alone
(except possibly on Intranet applications). After all, if it is based on
code by Yep (which I will happily accept as normally state of the art)
and it still isn't up to the task then it is almost certain that it just
cannot be done.

Richard.
Jul 20 '05 #8
Richard Cornford wrote:
Ivo wrote:
In IE you can write to the clipboard using
somevariable.ex ecCommand("Copy ");
JFTR Gecko offers a clipboardhelper component, which however requires
security privileges to be set. Still, implementing a copy feature in
other browsers is probably impossible, the way a browser should interact
with the OS has nothing to do with client-side scripting, so they'd
likely not offer an interface for doing so (IE and Mozilla, being
scripted outside a web environment, may have a legitimate reason to
provide such components).
... . Rightclick once and you get some silly options,
rightclick again and you get the default menu!

Or you get nothing, or just the original context menu, depending on the
browser. Supplementary context menus are just not achievable
cross-browser, which is why the best advice is to leave them alone
(except possibly on Intranet applications).
IMBW, but I like to make a difference between these system-related
contextual menus (which should, as you say, be left alone) and
document-related contextual menus (which after all are like any
navigational menu), easily created and called (for instance by a click
with a key modifier).
After all, if it is based on
code by Yep


Nope:-) The idea (alternate conceptual menus, a rather interesting
approach) and the code are by Ivo, I've just provided suggestions in
extending it for other UAs' DOMs.

(which I will happily accept as normally state of the art)

Beware not to! I'm just doing programming as a hobby, so the way I write
things is just as I feel them, it's not based on sound theoretical
knowledge or design experience.

Thank you very much for your positive comments, though; coming from such
skilled professional as yourself, they are highly appreciated and can
only encourage me in getting more serious in this field.
Cheers,
Yep.
Jul 20 '05 #9
Yann-Erwan Perio wrote:
Richard Cornford wrote:

<snip>
(which I will happily accept as normally state of the art)


Beware not to! I'm just doing programming as a hobby,
so the way I write things is just as I feel them, it's
not based on sound theoretical knowledge or design
experience.

<snip>

Be that as it may, I make my judgement on the code that I see. When you
post a complete solution what I see is just that: complete, form
conception through design to implementation. All of the permutations of
the execution environment considered and planed behaviour at the end of
every branch, and implemented to efficiently take advantage of the
language and its nature. Scripts that will get the best form whatever
browser they are exposed to, providing functional enhancements when they
can and cleanly degrading to viable underlying HTML when they can't.
Scripts that exemplify the appropriate use of javascript without being
trivial. (Subject to the occasional slips and omissions that being human
renders us all victims of.)

When so few people even perceive the intellectual challenge in Internet
browser script design, examples of authors that rise to the challenge
and produce scripts that fully address the issues are rare. You post
scripts that are consistently at the very top end of the range of
standards presented here (and often exhibit an aesthetic quality that
makes them interesting reading in their own right). If scripts among the
highest standard I see don't qualify as state of the art then I don't
know what would.

Richard.
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
23767
by: Sergio Otoya | last post by:
Hi all, Is there any way of copying a file using javascript, not using the Filesystemobject (ActiveX). I need this to run in Windows and MACS. Any help would be greatly appreciated. Thanks in advance. Sergio Otoya.
5
1753
by: Dev | last post by:
Hi I am creating a shopping cart webstie using VB.net. I want certain portions of my wesite to be copy protected like www.proware.com . The pages i want to protect are all dynamic Thankyou Dev
1
5627
by: Knepper, Michelle | last post by:
Hi out there, I'm a first-time user of the "Copy ... From..." command, and I'm trying to load a table from a text flat file. http://www.postgresql.org/docs/7.4/static/sql-copy.html I don't know if I'm using the command correctly. Question: I run this command as a superuser, and the "copy from" command is run like a SQL command on the command line, correct?
4
7039
by: Jon Asher | last post by:
Hi, I'm trying to do a simple import of a comma delimited text file with COPY but it's returning an error. The file has been granted all permissions in Linux, so it's not clear to me what the problem is. Version 7.41 is installed... see below for details: A comma delimited text file has been placed in a local directory with permissions set to allow any user to read or write to it: /root/Desktop/server_transfer/WorldPoints_v2.txt'
1
3540
by: Rachel McConnell | last post by:
Hi, I am trying to import data using COPY, from a file containing thirty or so COPY commands each with 0 or more rows of data. Reason, I have a small data set I want to include into a database with an identical schema, with existing data. I figured a good way to do this would be to use pg_dump on the small dataset, trim out the table definitions and constraints, and run the resulting file. (I also reordered the COPY statements to...
3
9224
by: Mateusz Rajca | last post by:
Hello, How can I add copy paste and cut to my browser in C#? I have the menu items labeled Copy, Paste and Cut. Now I just need the code? Mateusz
10
5150
by: jon | last post by:
I am a beginner C programmer, this is actually my first programming lanugage, besides html, cgi, and javascript. I am looking for a way to make an .exe file, or a copy of my own file. I have tried writing a file, compling it, and reading it in a notepad, then writing a program to write it again, but i have had no luck. I assure you i'm not trying to create the next big virus, or worm, but only trying to expaned my knowledge on what...
13
1844
by: Mounir | last post by:
Hi, Assume that right and left are multiple select elements. It's about the following line : right.options=left.options; It copies the content of left.options into right.options, but *removes* the content of the first one !
0
9575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9338
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6803
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.