Oli Warner About Contact Oli on Twitter Subscribe

Stop Annoying JavaScript

Thursday, 8 June 2006 browsers javascript networking

With the advent and uptake of Firefox, Opera and other “alternative” browsers [to IE], the Internet has become a much healthier place to roam around than it was a few years ago when you couldn’t move for popups, browsers were flying around users’ screens and browser exploits were everywhere.

Its not that there isn’t less dodgy code flying around, its that our browsers are coping with all the junk much better plus they’re getting regular updates unlike IE did/does.

Even though things have come this far, there are still sites that insist on pushing “annoying javascript” on people… I’m talking about sites that resize your windows mainly. When you only had one page per window in your old browser, if a page decided to resize it only resized that page. With tabbed browsing becoming the standard (even for the next final release of IE, if you haven’t seen IE7 yet), this sort of JavaScript has to die because I know I certainly don’t want 15 pages all being resized because of a page I go to for 5 seconds.

An example of such a page is the ScanAlert website which is linked to from all around the web declaring sites “Hacker Safe”. When you click the image, you’re linked to their details page about the site you’re on (have a look at their review of Experts-Exchange**WARNING** Annoying JS on page) and promptly attempts to resize your browser to a miniscule size.

This is by no means the only example of a site doing this Many sites with bad advertising on can spawn full-screen pop-unders and the like. I’ve seen other sites using variants of the following JavaScript function that prevents you from resizing your window.

window.resizeTo(800,600);
function NoResize(){
window.resizeTo(800,600);
}

Extremely annoying if they make the browser bigger than the screen.

Combating Annoying JS in Firefox

FireFox Options Screen

The first thing is to get yourself into the options screen of Firefox, accessible from the Tools >> Options… menu.

If you’re using the latest version of Firefox (1.5.0.4) you want to head for the tab labeled Content. If you’re using an older version you might be looking for a tab named Web Features.

In here you’re looking for checkbox and label that says Enable JavaScript. Do not disable this unless you want to block all javascript. Instead click the button along from it, labeled Advanced.

Advanced JS Options before

And here it is as it is after you do a default install of Firefox. Its already disabled status-bar-editing but still allows JS to resize and move windows, popping windows to the front and adding extra behavior to the right click context menu.

All of these can be annoying JavaScript at some point on the web. It really depends on how the developer has made the site. Disabling any of these could stop a site you need to use from working, which might be an issue for you, but if you don’t have any sites which do any of those things, I strongly suggest unchecking all of those checkboxes and clicking OK to both the open windows.

Advanced JS Options before

At the end of it, you should have something that looks a lot like this. If you need the feature reenabled, just come back to the screen and check the features you need.

The most important thing about all of this is you remember where the screen is, so you can turn things back on if you need to access a site that urgently needs these parts of javascript to function.

Doing this In Opera

Advanced JS Options before

The same sort of thing goes for Opera users. Head into Tools >> Preferences, click the Content tab, and then click the JavaScript options button. You’ll get a screen like this (Thanks to James for the screenshot) and you can uncheck all facets of JavaScript that you dislike.

You’ll notice that Opera has a few extra options (some especially useful for debugging your own scripts) but the options you want to nuke are all named near enough the same thing.

The final textbox is for specifying your own javascript files… “WHAT?!”, I hear you cry… There are lots of times where you might want to override the default bahaviour of things, and if you’re javascript endowed, you can write you own script to take over the page. If you’re not, you can also have a look at some of the wonderful scripts up on the Internet at UserJS.org.

Doing This In Other Browsers

As far as I can see there is no internal language choices for limiting JS on Internet Explorer 6. There could well be one on IE7 but I currently don’t have it installed to tell you or get screenshots.

If you know how to do this in IE or any other browsers, wang me a comment and I’ll get in contact with you about appending it to this article.

Conclusion

This doesn’t stop all the JavaScript on the Internet, but if you really want to do that unless you want lots of sites to break. Javascript is useful at times especially with AJAX on the rise.

These boxes should probably be unchecked for later builds of Firefox and Opera (as default behavior) until someone can point out how any of these “features” are actually useful.