Combining designMode on/off bookmarklets into one toggling bookmarklet

5.8k views Asked by At

I'm looking to combine these 2 bookmarklets into 1 bookmarklet that toggles the designMode on and off:

On: javascript:document.body.contentEditable='true';%20document.designMode='on';%20void%200

Off: javascript:document.body.contentEditable='false';%20document.designMode='off';%20void%200

I had tried some if else statements but can't seem to detect if designMode was on or not. So not sure what I was doing wrong. Any help would be appreciated.

2

There are 2 answers

3
srbrussell On BEST ANSWER

SOLVED (i had typos, oops) :

javascript:(

function () {
    if (document.documentElement.contentEditable === false || document.designMode === "off") {
        document.body.contentEditable='true';
        document.designMode='on';
        void 0;
    } else if (document.documentElement.contentEditable === true || document.designMode === "on") {
        document.body.contentEditable='false';
        document.designMode='off';
        void 0;
    }
})();
0
Alec Heehs On

This works on Google Chrome

   data:text/html, <html contenteditable>