Hi All,
I have a rather complicated problem.
I use following function to display a hyperlink:
a="<"+"a href='";
b3="<"+"a href='http://nww.";
L="</"+'a><br>';
function h(a){document.writeln(a)}
function HN(link,tekst){target=telt();if
(wi==1)target="_top";h(b3+link+"'"+tag+target+"'"+ "onclick='n(\""+target+"\",\""+"http://nww."+link+"\",\""+tekst+"\")'"+">"+tekst+L)}
Now I need an additional option to store a filename like:
function HN(link,tekst, filename)
The function HN should be rearranged that when I click this hyperlink
the filename gets stored to the clipboard, so I can release it with
Ctrl-V.
For Example:
HN('nix.nothing.int/WHERE/2005','My
Hyperlink','NIX.NOTHING.TEXT.20050723.')
Where the last part: NIX.NOTHING.TEXT.20050723. is the part which needs
to be copied to the clipboard.
Anyone knows how I should change the function HN to get this done?
Or is it not possible?
Regards
Marco
The Netherlands 18 2165 ma************@zonnet.nl wrote: The function HN should be rearranged that when I click this hyperlink the filename gets stored to the clipboard, so I can release it with Ctrl-V.
For Example: HN('nix.nothing.int/WHERE/2005','My Hyperlink','NIX.NOTHING.TEXT.20050723.')
Where the last part: NIX.NOTHING.TEXT.20050723. is the part which needs to be copied to the clipboard.
Anyone knows how I should change the function HN to get this done? Or is it not possible?
function HN(link, tekst, clipdata) {
// IE only
if (window.clipboardData) {
window.clipboardData.setData('text', clipdata);
}
...
}
JW
Janwillem,
Thanks for the help but where exactly should I add this piece of code?
Like this?
function HN(link,tekst,clipdata){
// IE only
if (window.clipboardData) {
window.clipboardData.setData('text', clipdata);
{target=telt();if
(wi==1)target="_top";h(b3+link+"'"+tag+target+"'"+ "onclick='n(\""+target+"\"
,\""+"http://nww."+link+"\",\""+tekst+"\")'"+">"+tekst+L)}
}
Marco
"Janwillem Borleffs" <jw@jwscripts.com> schreef in bericht
news:42***********************@news.euronet.nl... ma************@zonnet.nl wrote: The function HN should be rearranged that when I click this hyperlink the filename gets stored to the clipboard, so I can release it with Ctrl-V.
For Example: HN('nix.nothing.int/WHERE/2005','My Hyperlink','NIX.NOTHING.TEXT.20050723.')
Where the last part: NIX.NOTHING.TEXT.20050723. is the part which needs to be copied to the clipboard.
Anyone knows how I should change the function HN to get this done? Or is it not possible?
function HN(link, tekst, clipdata) { // IE only if (window.clipboardData) { window.clipboardData.setData('text', clipdata); } ... }
JW
Marco Krechting wrote: Janwillem,
Thanks for the help but where exactly should I add this piece of code? Like this?
function HN(link,tekst,clipdata){ // IE only if (window.clipboardData) { window.clipboardData.setData('text', clipdata); {target=telt();if (wi==1)target="_top";h(b3+link+"'"+tag+target+"'"+ "onclick='n(\""+target+"\" ,\""+"http://nww."+link+"\",\""+tekst+"\")'"+">"+tekst+L)} }
No, because this will render the function useless to other browsers then IE.
The only part that needs to be excluded from other browsers is the
window.clipboardData bit. Take the code I have shown you before and insert
the original function body below it:
function HN(link,tekst,clipdata){
// IE only
if (window.clipboardData) {
window.clipboardData.setData('text', clipdata);
}
// Original function body
target=telt();
// I assume wi is defined somewhere?
if (wi==1) {
target="_top";
}
h(....);
}
JW
I tried the code listed below but it doesn't work:
function HN(link,tekst,clipdata){
// IE only
if (window.clipboardData) {
window.clipboardData.setData('text', clipdata);
}
// Original function body
{target=telt();
if (wi==1)target="_top";
h(b3+link+"'"+tag+target+"'"+"onclick='n(\""+targe t+"\",\""+"http://nww."+li
nk+"\",\""+tekst+"\")'"+">"+tekst+L);
}
What went wrong?
Regards
MArco
"Janwillem Borleffs" <jw@jwscripts.com> schreef in bericht
news:42***********************@news.euronet.nl... Marco Krechting wrote: Janwillem,
Thanks for the help but where exactly should I add this piece of code? Like this?
function HN(link,tekst,clipdata){ // IE only if (window.clipboardData) { window.clipboardData.setData('text', clipdata); {target=telt();if
(wi==1)target="_top";h(b3+link+"'"+tag+target+"'"+ "onclick='n(\""+target+"\" ,\""+"http://nww."+link+"\",\""+tekst+"\")'"+">"+tekst+L)} }
No, because this will render the function useless to other browsers then
IE. The only part that needs to be excluded from other browsers is the window.clipboardData bit. Take the code I have shown you before and insert the original function body below it:
function HN(link,tekst,clipdata){ // IE only if (window.clipboardData) { window.clipboardData.setData('text', clipdata); }
// Original function body target=telt();
// I assume wi is defined somewhere? if (wi==1) { target="_top"; } h(....); }
JW
Marco Krechting wrote: I tried the code listed below but it doesn't work:
function HN(link,tekst,clipdata){ // IE only if (window.clipboardData) { window.clipboardData.setData('text', clipdata); }
// Original function body {target=telt(); if (wi==1)target="_top";
h(b3+link+"'"+tag+target+"'"+"onclick='n(\""+targe t+"\",\""+"http://nww."+li nk+"\",\""+tekst+"\")'"+">"+tekst+L); }
What went wrong?
You added an erroneous opening brace:
{target=telt();
This should be:
target=telt();
Please look again closely to the example in my previous reply.
JW
Ok, tried again, the function is working but all text after where I run it
on the age is missing.
function HN(link,tekst,clipdata){
// IE only
if (window.clipboardData) {
window.clipboardData.setData('text', clipdata);
}
// Original function body
target=telt();
// I assume wi is defined somewhere?
if (wi==1) {
target="_top";
}
h(b3+link+"'"+tag+target+"'"+"onclick='n(\""+targe t+"\",\""+"http://nww."+li
nk+"\",\""+tekst+"\")'"+">"+tekst+L);
}
HN('nix.com/2005/','My Daily Report','DAILY.REPORT.')
------> after this all code on the page is missing....
Marco
"Janwillem Borleffs" <jw@jwscripts.com> schreef in bericht
news:42***********************@news.euronet.nl... Marco Krechting wrote: I tried the code listed below but it doesn't work:
function HN(link,tekst,clipdata){ // IE only if (window.clipboardData) { window.clipboardData.setData('text', clipdata); }
// Original function body {target=telt(); if (wi==1)target="_top";
h(b3+link+"'"+tag+target+"'"+"onclick='n(\""+targe t+"\",\""+"http://nww."+li nk+"\",\""+tekst+"\")'"+">"+tekst+L); }
What went wrong?
You added an erroneous opening brace:
{target=telt();
This should be:
target=telt();
Please look again closely to the example in my previous reply.
JW
Marco Krechting wrote: Ok, tried again, the function is working but all text after where I run it on the age is missing.
Let's breakdown the function:
target=telt();
Is the telt() function correctly defined?
if (wi==1) {
Is wi defined as a global variable?
h(b3+link+"'"+tag+target+"'"+"onclick='n(\""+targe t+"\",\""+ "http://nww."+link+"\",\""+tekst+"\")'"+">"+tekst+L);
Is the h() function correctly defined?
Are the following variables globally defined:
b3
tag
L
Note that when variables not defined globally, should be defined in the
function itself.
BTW, a good JS debugging tool is FireFox's javascript console.
JW
Everything was working fine until I entered the copy clipboard code.
b3 = "<"+"a href='http://nww.";
tag = "target='"
L = "</"+'a><br>';
tel=0;function telt(){tel++;return tel};
I tried to use Firefox JS console, but how do I check a complete html-file?
Marco
"Janwillem Borleffs" <jw@jwscripts.com> schreef in bericht
news:42***********************@news.euronet.nl... Marco Krechting wrote: Ok, tried again, the function is working but all text after where I run it on the age is missing.
Let's breakdown the function:
target=telt();
Is the telt() function correctly defined?
if (wi==1) {
Is wi defined as a global variable?
h(b3+link+"'"+tag+target+"'"+"onclick='n(\""+targe t+"\",\""+ "http://nww."+link+"\",\""+tekst+"\")'"+">"+tekst+L);
Is the h() function correctly defined?
Are the following variables globally defined:
b3 tag L
Note that when variables not defined globally, should be defined in the function itself.
BTW, a good JS debugging tool is FireFox's javascript console.
JW
Marco Krechting wrote: Everything was working fine until I entered the copy clipboard code.
So everything works fine again when you remove the clipboard code?
I tried to use Firefox JS console, but how do I check a complete html-file?
Just call the script in FireFox, then look into the JS console to see if
there are errors.
JW
Janwillem Borleffs wrote: Just call the script in FireFox, then look into the JS console to see if there are errors.
That is: call the page that includes the script in FireFox. If this doesn't
bring up errors, then post an URL where the page can be viewed somewhere.
JW
Got three time the error: Dialog has no properties
and this one (I don't know what it means):
Error: uncaught exception: [Exception... "Component returned failure
code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowInternal.focus]"
nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
chrome://global/content/bindings/tabbrowser.xml :: setFocus :: line
638" data: no]
Marco ma************@zonnet.nl wrote: Got three time the error: Dialog has no properties
and this one (I don't know what it means): Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowInternal.focus]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://global/content/bindings/tabbrowser.xml :: setFocus :: line 638" data: no]
Do you programmatically create a popup window anywhere in your code? Does
the script work when you remove the window.clipboardData bit?
The following code works without any problems in both IE and FireFox:
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function test(text, clipdata) {
if (window.clipboardData) {
window.clipboardData.setData('text', clipdata);
}
document.write(text);
}
</script>
</head>
<body>
<script>test('Hello', 'World');</script>
</body>
</html>
Are you doing something simular or are you calling the HN function when the
page is already done loading? In that case it's important that the h()
function does not use document.write as this will wipe out the initial page
including the scripts.
JW
The problem appears to be that the window.clipboardData.setData() function
expects a string as the second argument and sometimes it's an integer.
Changing the call into:
if (window.clipboardData) {
window.clipboardData.setData('text', '' + clipdata);
}
will fix this...
JW
With this new code it now works fine:
function setClip(clipdata) {
if (window.clipboardData) {
window.clipboardData.setData('text', clipdata);
}
}
function HN(link,tekst,clipdata) {
target=telt();
if (wi==1) {
target="_top";
}
text2write = b3 + link + "'" + tag + target + "'";
text2write += "onclick='setClip(\"" + clipdata + "\");";
text2write +=
"n(\""+target+"\",\""+"http://www."+link+"\",\""+tekst+"\")'";
text2write += ">" + tekst + L;
h(text2write);
}
thanks a lot JW
MArco
Hi ,
This is a very intersting discussion thats going on. Now i tried doing
absolutely the same thing in FireFox and it just did not work. There are
2 things that i tried
1) <script language="javascript" type="text/javascript">
function sendToClipboard(s){
window.clipboardData.setData('text', "123456789");
}
When i do this, i get the follwoing error in the JavaScript Console of
Firefox -:
Error: window.clipboardData has no properties
Source File: file:///C:/Ankur/Test/CopyTest.html
Line: 15
2) And when i try to do something like this -:
<script language="javascript" type="text/javascript">
function sendToClipboard(s){
if( window.clipboardData && clipboardData.setData ){
alert("In the IF loop with s being " + s);
window.clipboardData.setData("Text", s);
}else{
alert("In the ELSE loop ");
}
}
</script>
In this case , it does not even go to the IF loop. It just goes to the
else and comes out.
Any advise will be really appreciated. Thanks in advance
*** Sent via Developersdex http://www.developersdex.com ***
Ankur Vedi wrote: This is a very intersting discussion thats going on. Now i tried doing absolutely the same thing in FireFox and it just did not work.
That's the whole idea of the condition; FireFox does not support
window.clipboardData, so you cannot populate data to the clipboard using JS
with this browser...
JW
Hi JW,
Thanks a bunch for your reply and clearing that doubt.
Now if you are saying that window.clipboardData cannot be used with
Firefox, then can you please advise as to how may i achieve the same
functionality in Firefox, ie copying some data on the browser so that i
can paste it later somewhere using Ctrl V .
Thanks Again
Ankur
*** Sent via Developersdex http://www.developersdex.com ***
Ankur Vedi wrote: Now if you are saying that window.clipboardData cannot be used with Firefox, then can you please advise as to how may i achieve the same functionality in Firefox, ie copying some data on the browser so that i can paste it later somewhere using Ctrl V .
I don't think it is possible in FireFox without a special extension like the
one found at: http://www.gratisdei.com/copytoclip.xpi
JW This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Harag |
last post by:
Hi all
If I create an object with the following:
var ob1 = new objMyDefinedObject();
then I assign it to a new variable.
var ob2 = ob1
|
by: @sh |
last post by:
I know this is probably a real simple one, but I'm obviously missing
something..
I'm building a function that I'll use throughout a website in the situation
that I have two text boxes - the two...
|
by: charles-brewster |
last post by:
I'm trying to write a simple JavaScript function which will use a
button to copy table cell data into a form input text box as the
"value" attribute.
The following is intended to test the...
|
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...
|
by: zakhirn |
last post by:
Hello,
I have a search function that is reading companies from a database via
ASP and spitting out the results. I have various fields of each company
in variables and I want to be able to create...
|
by: zakhirn |
last post by:
Hello,
I have a search function that is reading companies from a database via
ASP and spitting out the results. I have various fields of each company
in variables and I want to be able to create...
|
by: Wouter |
last post by:
Hi,
I try to make the follow. I want that i can click on a text link and that
then a link wil be copyed in a input form box (<input type="text"
name="img_url" />).
I have google-ed about how...
|
by: Sillu |
last post by:
I'ld like to create a web page, from which no one can select the text
simply, copy frm there n paste at another location. In simple means,
i'ld like to stop copy process from my web page. Plz...
|
by: WaterWalk |
last post by:
Hello. Suppose there is an implementation of C++, in which when a
class object is allocated, its member functions are also allocated in
addition to its data members. So that every class object has...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |