Question

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".

Was it helpful?

Solution

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);

OTHER TIPS

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

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

Are there any other ways?

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

Regardless, your revised scripts works fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top