8

I have an HTML element in my web page on iPad and it must be read only to prevent users updating the content,using readOnly='readOnly' makes the element unselectable and text content of the element can not be copied at all.

is there any way to make the element read only and the user can select/copy the text content????

Cœur
  • 37,241
  • 25
  • 195
  • 267
aomar
  • 500
  • 1
  • 6
  • 23
  • 3
    I voted to reopen this question. This question is very different than the linked duplicate question. – Brian Jun 20 '13 at 23:54
  • 1
    Agreed. This issue is specific to iPad text input fields and the readOnly attribute and the answer below from aomar is the only solution I've encountered. – peater Jun 13 '14 at 14:53

1 Answers1

12

just i removed the readOnly attribute and added the following onkeydown and oncut events to simulate readOnly behavior

<input type="textarea" 
    onkeydown="event.preventDefault();event.stopPropagation();return false;" 
    oncut="event.preventDefault();event.stopPropagation();return false;">
Sander Rijken
  • 21,376
  • 3
  • 61
  • 85
aomar
  • 500
  • 1
  • 6
  • 23