Search code examples
javascriptgoogle-chromebookmarkletbookmarks

Is there a way to create a document.editable toggle?


I would like to know if it is possible to turn this into a toggle so if you click it and the content is editable, it makes it not editable, same thin flipped.

Here is the code javascript:document.body.contentEditable='true'; document.designMode='on'; void 0


Solution

  • It's pretty easy with a Ternary operator. Here you go:

    javascript: document.body.contentEditable = document.body.contentEditable=='false'?'true':'false'; document.designMode=document.designMode=='on'?'off':'on';document.close();alert(document.body.contentEditable + document.designMode);
    

    Take off the alert() at the end when you're sure it's working like you want.