Gautham Renganathan
Gautham Renganathan

Reputation: 645

How do I create a non content editable div inside a content editable iframe?

I need to make a some parts inside an contenteditable iframe as non-editable. How do I do that? The below code works in chrome but not in firefox. Everything is editable in firefox. Ineed the checkbox to be noneditable

<iframe contentEditable="true" >
    Editable text<div contentEditable="false"><input type="checkbox" /></div>
</iframe>

Upvotes: 4

Views: 9193

Answers (2)

Pierre Gourlaouen
Pierre Gourlaouen

Reputation: 21

I found a solution with an input text with an attribut readonly. I found the width of the input with a span invisible and I got the width of the span outside of my contenteditable.

Works like a cham !

Upvotes: 0

William Buttlicker
William Buttlicker

Reputation: 6000

Use this:

Editable text<div contentEditable="false" readonly>Non content editable text</div>

If you want to use JQuery:

$('#divId').attr('readonly', 'true');

Upvotes: 9

Related Questions