tags:

views:

89

answers:

3

I want to create a bookmarklet that sets the page to be editable, that is, to run this code:

javascript:document.body.contentEditable=true;

When I made a bookmark of that, I could see that the page becomes editable very briefly and then the whole thing is replaced with the word "true".

A: 

After a bit of random trial and error, I found that this worked:

javascript:(function() { document.body.contentEditable=true; })()

Are there any other ways?

nickf
A: 

Some sites suggest that you use document.designMode=’on’, but that doesn't work for me.

Regardless, your revised scripts works fine.

EndangeredMassa
+1  A: 

Bookmarklets have to evaluate to void for the browser stay on the same page. Just end it with a void(0):

javascript:document.body.contentEditable=true;void(0);
weiyin