I am trying to write a bookmarklet that toggles the ability to make any text on the page editable, but when I execute it, it seems to be performing something along the lines of document.write('off')
. Here's the code/bookmarklet:
javascript: if (document.body.contentEditable == "true") {
document.body.contentEditable = "true";
document.designMode = 'on';
} else {
document.body.contentEditable = "false";
document.designMode = "off"
}
try an IIFE
javascript:(function(){if (document.body.contentEditable == "true") {
document.body.contentEditable = "true";
document.designMode = 'on';
} else {
document.body.contentEditable = "false";
document.designMode = "off"
}})()