[Javascript] Allow select on disabled field

Arno Kuhl akuhl at telkomsa.net
Fri Sep 4 02:41:33 CDT 2009


I'm trying to do copy-to-clipboard in javascript. It works fine in IE but FF
needs to have preferences changed by the user to allow it, so another option
I'm looking at is to just select/mark the data in FF and allow the user to
manually copy to clipboard. So the code detects the browser and displays a
Copy button in IE and a Mark button in FF. The data is often longer than the
display length of the text field, I don't want to use a textarea (though I
will if it solves the problem) and don't want to allow user to change the
displayed data so I set the field to disabled='true'. In IE I can select the
data (with mouse or js) and copy manually (though my js function can already
do that anyway) but in FF I can't select the data, and the code for FF

   document.urllink.focus();
   document.urllink.select();

fails on the focus() line because FF won't allow focus on a disabled field.
 
Is there a way I can select data in an input field in FF (ready to be copied
to clipboard) but still disable edit?
 
Cheers
Arno




More information about the Javascript mailing list