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.

You May Also Like

About the Author: rnowik

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.