posted 15 years ago
Hi,
I am trying to implement the copy to clipboard functionality using javascript.
Here is my function :
function copyText(field)
{
if(document.all){
var content = eval("document."+field)
content.focus()
content.select()
range = content.createTextRange()
range.execCommand("Copy")
window.status="Contents copied to clipboard"
setTimeout("window.status=''",1800)
}else{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"];
const setClbHelper=gClipboardHelper.getService(Components.interfaces.nsIClipboardHelper);
setClbHelper.copyString("<%=urlBuffer%>");
}
}
Where the parameter field is myForm.txtBox and i am having my text in this box which has to be copied.
When i work on the Firefox, this works fine but it does not work on IE.
But when i invoke only IE related part, it works fine on IE.
The issue comes up when i use if and else to check for the browser and IE does not copy when i have the Firefox related code in the else.
Could any one help me point the error.
Thanks,
hari