Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape clipboard

Status
Not open for further replies.

fluxdemon

MIS
Nov 5, 2002
89
US
Does anybody have code to copy text to the clipboard in Netscape
 
I may be wrong but I thought the clipboad was a function of the Windows API, not the browser.

There's always a better way. The fun is trying to find it!
 
I'm using a hyperlink and Javascript to copy text to the clipboard.
 
can i have the code?

Known is handfull, Unknown is worldfull
 
Here it is. I found something that works part of the way. In the testing of it I have what I want until it gets passed to the last four statments in the netscape section of the function. The output text should be
&#(somenumber);

<!--#include file=&quot;functions.asp&quot;-->
<!--#include file=&quot;header.asp&quot;-->

<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
<!--

function copyTo(strVar)
{

if(window.clipboardData)
{
window.clipboardData.setData(&quot;text&quot;, strVar);
}

else if(window.netscape)
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;

var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans) return;

trans.addDataFlavor('text/unicode');

var str = new Object();
var len = new Object();

var str = Components.classes[&quot;@mozilla.org/supports-string;1&quot;].createInstance(Components.interfaces.nsISupportsString);

str.data=strVar;

trans.setTransferData(&quot;text/unicode&quot;,str,strVar.length*2);

var clipid=Components.interfaces.nsIClipboard;

if (!clip) return false;

clip.setData(trans,null,clipid.kGlobalClipboard);

}
return false;
}

-->
</script>


<% main() %>

<%
Set MyBrow=Server.CreateObject(&quot;MSWC.BrowserType&quot;)
if MyBrow.browser<>&quot;IE&quot; then
%>
<br><br>
<%
else
%>
<br>
<%
end if
%>
<table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;100%&quot;>
<tr>
<td align=&quot;left&quot;>
<form name=&quot;frmRange&quot; action=&quot;escape.asp&quot; method=&quot;post&quot;>
<select name=&quot;lstSections&quot; onkeypress=&quot;if(event.keyCode==13) document.frmRange.submit();&quot; onFocus=&quot;frmRange.manualInput.value='';&quot;>
<option value=&quot;&quot;>--none--</option>
<option value=&quot;48-57,65-90,97-122&quot;> AlphaNumeric </option>
<option value=&quot;884-885,890,894,900-906,908,910-929,931-974,976-982,986,988,990,992,994-1011&quot;> Greek and Coptic </option>
<option value=&quot;9728-9839&quot;> Misc Symbols </option>
<option value=&quot;8592-8682&quot;> Arrows </option>
<option value=&quot;9985-9988,9990-9993,9996-10023,10025-10059,10061,10063-10066,10070,10072-10078,10081-10087,10102-10132,10136-10174&quot;> Dingbats </option>
<!--option value=&quot;&quot;> </option-->
</select>
<input type=&quot;text&quot; name=&quot;manualInput&quot; onFocus=&quot;frmRange.lstSections.value=''&quot;>
</form>
</td>
<td align=&quot;right&quot;>
<table align=&quot;right&quot;>
<tr>
<td valign=&quot;bottom&quot;><form action=&quot; onload=&quot;load()&quot; onbeforeunload=&quot;unld()&quot;><input size=40 name=q></form></td>
<td align=&quot;right&quot; valign=&quot;top&quot;><font color=&quot;c0c0c0&quot; size=4 face=&quot;comic sans ms&quot;><strong>Google </strong></font></td>
</tr>
</table>
</td>
</tr>
</table>

<%



dim arrRange,strRange,tmp,value,strVar,tmpVar1,tmpVar2

strRange = request.form(&quot;lstSections&quot;) & request.form(&quot;manualInput&quot;)

if strRange<>&quot;&quot; then


arrRange=split(strRange,&quot;,&quot;)
dim i

if MyBrow.browser<>&quot;IE&quot; then
response.write(&quot;<br>&quot; & chr(10))

for i=Lbound(arrRange) to Ubound(arrRange)

tmp=inStr(arrRange(i),&quot;-&quot;)

if(tmp<>0) then
value=split(arrRange(i),&quot;-&quot;)

tmpVar1=value(0)
tmpVar2=value(1)
for tmpVar1=tmpVar1 to tmpVar2
strVar = chr(39) & chr(38) & chr(35) & &quot;38&quot; & chr(59) & chr(38) & chr(35) & &quot;35&quot; & chr(59) & tmpVar1 & chr(38) & chr(35) & &quot;59&quot; & chr(59) & chr(39)
response.write(&quot;<a class=&quot; & chr(34) & &quot;escape&quot; & chr(34) & &quot; href=&quot; & chr(34) & &quot;#&quot; & chr(34) & &quot; onClick=&quot; & chr(34))
response.write(&quot;return copyTo(&quot; & strVar & &quot;);&quot; & chr(34) & &quot; title=&quot; & strVar & &quot;>&quot;)
response.write(chr(38) & chr(35) & tmpVar1 & chr(59))
response.write(&quot;</a>&quot; & chr(10))
next

response.write(&quot;<br>&quot; & chr(10))

else

tmpVar1=arrRange(i)
tmpVar2=0
strVar = chr(39) & chr(38) & chr(35) & &quot;38&quot; & chr(59) & chr(38) & chr(35) & &quot;35&quot; & chr(59) & tmpVar1 & chr(38) & chr(35) & &quot;59&quot; & chr(59) & chr(39)
response.write(&quot;<a class=&quot; & chr(34) & &quot;escape&quot; & chr(34) & &quot; href=&quot; & chr(34) & &quot;#&quot; & chr(34) & &quot; onClick=&quot; & chr(34))
response.write(&quot;return copyTo(&quot; & strVar & &quot;);&quot; & chr(34) & &quot; title=&quot; & strVar & &quot;>&quot;)
response.write(chr(38) & chr(35) & tmpVar1 & chr(59))
response.write(&quot;</a>&quot; & chr(10))
response.write(&quot;<br>&quot; & chr(10))
strVar=&quot;&quot;
end if

next

else
response.write(&quot;<br>&quot; & &quot;<br>&quot; & chr(10))

for i=Lbound(arrRange) to Ubound(arrRange)

tmp=inStr(arrRange(i),&quot;-&quot;)

if(tmp<>0) then
value=split(arrRange(i),&quot;-&quot;)

tmpVar1=value(0)
tmpVar2=value(1)
for tmpVar1=tmpVar1 to tmpVar2
strVar = chr(39) & chr(38) & chr(35) & &quot;38&quot; & chr(59) & chr(38) & chr(35) & &quot;35&quot; & chr(59) & tmpVar1 & chr(38) & chr(35) & &quot;59&quot; & chr(59) & chr(39)
response.write(&quot;<a class=&quot; & chr(34) & &quot;escape&quot; & chr(34) & &quot; href=&quot; & chr(34) & &quot;#&quot; & chr(34) & &quot; onClick=&quot; & chr(34))
response.write(&quot;return copyTo(&quot; & strVar & &quot;);&quot; & chr(34) & &quot; title=&quot; & strVar & &quot;>&quot;)
response.write(chr(38) & chr(35) & tmpVar1 & chr(59))
response.write(&quot;</a>&quot; & chr(10))
next

response.write(&quot;<br>&quot; & chr(10))

else

tmpVar1=arrRange(i)
tmpVar2=0
strVar = chr(39) & chr(38) & chr(35) & &quot;38&quot; & chr(59) & chr(38) & chr(35) & &quot;35&quot; & chr(59) & tmpVar1 & chr(38) & chr(35) & &quot;59&quot; & chr(59) & chr(39)
response.write(&quot;<a class=&quot; & chr(34) & &quot;escape&quot; & chr(34) & &quot; href=&quot; & chr(34) & &quot;#&quot; & chr(34) & &quot; onClick=&quot; & chr(34))
response.write(&quot;return copyTo(&quot; & strVar & &quot;);&quot; & chr(34) & &quot; title=&quot; & strVar & &quot;>&quot;)
response.write(chr(38) & chr(35) & tmpVar1 & chr(59))
response.write(&quot;</a>&quot; & chr(10))
response.write(&quot;<br>&quot; & chr(10))
strVar=&quot;&quot;
end if

next

end if

end if

strRange =&quot;&quot;

%>

<!--#include file=&quot;footer.asp&quot;-->
 
this wont work in NS. clipboard is supported only by IE...

Known is handfull, Unknown is worldfull
 
So... how do I modify this to get it to work. Like I said the variables have the right information until the last four lines. The same code works in Mozilla's Firebird.
 
it wont work in NS as the browser just does not accept the clipboard object (in its JVM). i think the netscape home site will yield u the best results...

Known is handfull, Unknown is worldfull
 
It turns out that Netscape 7.1 uses the clipboard the same way as IE. But I would like to have the older browsers covered as well.
 
like is said thats browser specific. like DOM doesnt work in NS4.x versions... even simple javascript functions dont work.

i think u should be happy that it works atleast in NS 7.1...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top