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.
Asked
Active
Viewed 30 times
-1

Komali
- 77
- 10
1 Answers
2
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;

Derek 朕會功夫
- 92,235
- 44
- 185
- 247
-
Could you please explain what "void 0;" does? I am just learning JS – Komali Feb 28 '18 at 16:00
-
@Konstrictor [It's just a shorter way to write `;undefined;`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void) – Derek 朕會功夫 Feb 28 '18 at 16:01