Why does appending to innerHTML in a bookmarklet overwrite the entire page?

bookmarklet, javascript

Solution

You are not cancelling the action. add void 0; to then end.

javascript:document.getElementsByTagName("div")[0].innerHTML+="Chuck Norris";void 0;

Problem

I have this little bookmarklet: ``` javascript:document.getElementsByTagName("div")[0].innerHTML+="Chuck Norris"; ``` Now it's obviously supposed to take the very first `div` on the page, and add Chuck Norris into it. Instead, when pasted on the address bar, Chuck Norris overwrites the page. Why is this so? Note: this doesn't occur on Safari...

Original source