ben03 Posted September 23, 2008 Share Posted September 23, 2008 Am using the <textarea> tags to place code in a page to be copied by users. Is there a way to stop code being 'cut' (removed) from the box? Cheers Link to comment Share on other sites More sharing options...
boen_robot Posted September 23, 2008 Share Posted September 23, 2008 I thnk making it readonly should do it: <textarea readonly="readonly"></textarea> Link to comment Share on other sites More sharing options...
aspnetguy Posted September 23, 2008 Share Posted September 23, 2008 that only prevents the user from typing in the textarea. I can still copy and paste into a text editor.The only way I know to stop this is to place a transparent div (the same size as the textarea) over top of the textarea. Link to comment Share on other sites More sharing options...
jeffman Posted September 23, 2008 Share Posted September 23, 2008 But the transparent div will prevent copying, which seems to be contrary to the point.You could disable the textarea, maybe, though that messes with the color.I suspect ben03's reason for using a textarea instead of a div is so you can include HTML tags without having the tags be interpreted as tags? One way around that is to replace your opening "<" characters with "<". When the user copies, the entity will be copied as the character.(I actually don't know if that's true in all browsers, but it should be.) Link to comment Share on other sites More sharing options...
aspnetguy Posted September 23, 2008 Share Posted September 23, 2008 okay disregard what I said. I don't know what I read the first time but I clearly misunderstood. Boen is correct the text can't be cut from the textarea. Link to comment Share on other sites More sharing options...
ben03 Posted September 29, 2008 Author Share Posted September 29, 2008 Will try the code out. Cheers for the help guys. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.