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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -