Combining designMode on/off bookmarklets into one toggling bookmarklet
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.d开发者_C百科esignMode='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.
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;
}
})();
This works on Google Chrome
data:text/html, <html contenteditable>
精彩评论