It tells the browser that it displays the result of executing an empty string literal. Therefore, it simply displays an empty string.
You can check the effect of this by entering javascript:'http://qaru.site/'; in the address bar of a regular window / tab. You will get a white page with the inscription " /qaru.site / ... ", and in fact you will not get to this URL.
This is the reason why bookmarklets often wrap code inside void() or an anonymous function that returns nothing to stop the browser from trying to display the result of the bookmarklet. For example:
javascript:void(window.open("dom_spy.html"))
Or:
javascript:(function () { window.open("dom_spy.html"); })()
If you use code that returns something (in this case, an instance of a new window), the browser will ultimately display the following:
javascript:window.open("dom_spy.html");
In Firefox above will be displayed:
[object Window]
Ates Goral Jan 10 '09 at 1:44 2009-01-10 01:44
source share