Search code examples
javascriptbookmarklet

Keep Body while changing the title


I am working with JS bookmarklets and I am playing around withjavascript:document.title = "WHATEVAH". However, when I use that by itself, it removes all content on the page. So then I tried javascript:document.title = "WHATEVAH";document.body.innerHTML = document.body; but that didn't work either. Please explain what I am doing wrong, and how I can fix it.


Solution

  • You have to return undefined at the end, otherwise it's going to navigate to a blank page. A common way of doing it is to do:

    javascript:document.title = "WHATEVAH"; void 0;