html - Edit webpage with javascript trick - how to "unedit"? -
i can use following scriptlet make webpage editable
javascript:document.body.contenteditable='true'; document.designmode='on'; void 0
but after doing edits want (e.g., screenshot manual), how restore state of page normal uneditable state? have tried changing true
, 0
false
, 1
respectively, no avail.
you need remove contenteditable
attribute.
var demo_editable = document.getelementbyid('demo-editable'); var demo_button = document.getelementbyid('demo-button'); demo_editable.setattribute('contenteditable',true); demo_button.onclick = function() { delete demo_editable.removeattribute('contenteditable'); }
<div id="demo-editable">this editable</div><button id="demo-button">make not editable</button>
or can set attribute false.
var demo_editable = document.getelementbyid('demo-editable'); var demo_button = document.getelementbyid('demo-button'); demo_editable.setattribute('contenteditable',true); demo_button.onclick = function() { delete demo_editable.setattribute('contenteditable',false); }
<div id="demo-editable">this editable</div><button id="demo-button">make not editable</button>
Comments
Post a Comment