473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

copying a string to clipboard in IE4

I need a utility that will basically add a "Copy OnClick Event" to my
right click context menu in Internet Explorer IE. I am a super newbie
in javascript. The following code works for IE5, but not for IE4,
which doesnt have setdata, getdata, etc. methods for dealing with the
clipboard. The folowing code is invoked by a registry context menu
entry. When I looked at IE4's copy system uses execcommand, it only
works on something that is selected as far as I can see, I dont have
anything selected, because user isnt going be highlighting, and that
wont get the onclick attribute value. All I have is a variable string
in javascript with what I need to get into the clipboard. How can I
make this code work in IE4, so I dont need to force users to get IE5?

<SCRIPT LANGUAGE="JavaScript">
var clipRes;

var parentwin = external.menuArguments;
var doc = parentwin.document;
var actele = doc.activeElement;
var attrib = actele.attributes;
var oc = attrib.onclick;
var str = oc.nodeValue;

alert(str);
clipRes = parentwin.clipboardData.setData("Text",str);
alert(clipRes);

</SCRIPT>
Jul 23 '05 #1
4 1533
On 25 Nov 2004 08:25:27 -0800, buildmorelines <bu****@hotmail.com> wrote:
How can I make this code work in IE4, so I dont need to force users to
get IE5?
You can't. The best you can do is test for support before executing the
code (preferably before adding the item) so that you don't trigger errors.

if(window.clipboardData) {
// object supported
}

would do.
<SCRIPT LANGUAGE="JavaScript">


The language attribute has been deprecated for over six years. Use the
(required) type attribute, instead:

<script type="text/javascript">

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
buildmorelines wrote:
I need a utility that will basically add a "Copy OnClick Event" to my
right click context menu in Internet Explorer IE. I am a super newbie
in javascript. The following code works for IE5, but not for IE4,
which doesnt have setdata, getdata, etc. methods for dealing with the
clipboard. The folowing code is invoked by a registry context menu
entry. When I looked at IE4's copy system uses execcommand, it only
works on something that is selected as far as I can see, I dont have
anything selected, because user isnt going be highlighting, and that
wont get the onclick attribute value. All I have is a variable string
in javascript with what I need to get into the clipboard. How can I
make this code work in IE4, so I dont need to force users to get IE5?


Apart from what has already been said. If IE4 can copy selected text,
then you can set the value of an input to the string you have, select it
all, then copy it to the clipboard.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message news:<opsh04pbjex13kvk@atlantis>...
On 25 Nov 2004 08:25:27 -0800, buildmorelines <bu****@hotmail.com> wrote:
How can I make this code work in IE4, so I dont need to force users to
get IE5?


You can't. The best you can do is test for support before executing the
code (preferably before adding the item) so that you don't trigger errors.

if(window.clipboardData) {
// object supported
}

would do.
<SCRIPT LANGUAGE="JavaScript">


The language attribute has been deprecated for over six years. Use the
(required) type attribute, instead:

<script type="text/javascript">

[snip]

Mike

Is there any ActiveX control I could use to control the clipboard from
IE4, the security zone inside the context menu script is low enough to
use Wscript.Shell control?

There was also some code about making a hidden value in the document
then creating a textrange on it, and then execcommand('copy') or
something, but since the javascript code isnt exactly running in the
original webpage window it doesnt seem to work (I did change it to
refer to the window object of the original page).
Jul 23 '05 #4
On 25 Nov 2004 17:56:00 -0800, buildmorelines <bu****@hotmail.com> wrote:

[snip]
Is there any ActiveX control I could use to control the clipboard from
IE4, the security zone inside the context menu script is low enough to
use Wscript.Shell control?


I'm afraid I couldn't say.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #5

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

Similar topics

8
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a...
0
by: Ata | last post by:
Hello, I am trying to copy the contents of the output of SQL Reporting Services to a PowerPoint slide. For this, I am using SQL Reporting Services to obtain an IMAGE stream, which I paste to the...
12
by: Robert Mens | last post by:
Hi, how is it possible to check if an \n appears in a string to process the data before the \n and then stack up the following data until another \n appears? I need this for something with...
8
by: John Smith | last post by:
Hi folks, I know how to place text into the user's clipboard: Clipboard.SetDataObject("My Copied Text"); but how do I place a file in there? So, if I have a file C:\test.txt, how can I place...
8
by: John | last post by:
Hi How can I copy some text to the clipboard so it can be pasted into other apps? Thanks Regards
9
by: Christian Blackburn | last post by:
Hi Gang, I don't know what to make of all of this, but I'm having nothing, but trouble copying data to the clipboard which should be the easiest thing in the world. The only systems I can get...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
2
by: alastairgarrow | last post by:
Hi there I am looking for some help in getting a clipboard image into an Sql Database table. My plan is to have a web page that will allow the user to copy an image on their home computer and...
3
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
One more for today.... As I add more and more lines to my RichTextBox the array that holds its strings gets bigger and bigger and the vertical scroll bar gets smaller and smaller until the...
23
by: Over | last post by:
Hi it's possible with language C, (Mingw or Djgpp) copying the clipboard of WinXp into file.txt? which function must be use. Thanks
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...

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.