JavaScript: Setting up a scrollable readonly text box

To make a text area readonly through JavaScript whilst allowing the scrollbar to function correctly do the following:

document.getElementById(“theTextArea”).readOnly = true;
document.getElementById(“theTextArea “).style.color = “#777″;
document.getElementById(“theTextArea”).style.backgroundColor = “#EEE”;

Alternatively, you could do document.getElementById(“theTextArea”).disabled = true; but the scrollbar on the text area will not function and you will not be able to see any overflowing text.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>