views:

20

answers:

2

In most browsers if you enter javascript:$('element').css('property', 'value');

will result in the javascript code being run.

In firefox this will cause the page to change to a blank white page with [object] [object]

why is this?

+3  A: 

Because Firefox shows the return value of that function. Add void(0); after it to avoid a page redirect. Example:

javascript:$('element').css('property', 'value');void(0);

My preffered way to run code in URLs:

javascript:void(function(){ /*code here*/ })();

In this way, you don't mess with the global namespace:

javascript:var y=1;alert(y);void(0);

Here, window.y contains now 1, whereas window.y is undefined below:

javascript:void(function(){var y=1;alert)y)})();
Lekensteyn
A: 

Just add:

void(0);

at the end.

Matthew Flaschen