Google-chrome – With Chrome how to use the the javascript: URL pseudoprotocol

google-chromejavascript

With Firefox I can type in the location bar "javascript:" followed by some JavaScript code and have this code executed and the result displayed in the page. For example javascript:x = 3 displays 3 in the page.

However with Chrome nothing is displayed. Is there a way to do this in Chrome?

Best Answer

You could do something like:

javascript:x=3;alert(x)

Or:

javascript:x=3;document.write(x)

At least on Chrome for OS X, neither of these work on the new tab page; you must first open any other page first. Loading about:blank does just fine.

Related Question