31st August 2007

Javascript not working in Safari? This might help…

If JavaScript has suddenly stopped working – or is working only sporadically – in your Apple Safari browser, even though you have it enabled in your Safari Preferences, I might be able to you……..after spending weeks trying to figure this one out I stumbled across a solution quite by accident.

I have the Debug menu enabled (if you do it appears in your menu bar after the Help menu item, if you don’t have it read on for an explanation of what it is and does below), and had the option to “Log Javascript Exceptions” enabled from the Debug menu. This can be a handy feature if you’re trying to diagnose your own JavaScript, but watch out! If your Log File (the JavaScript Console) gets full it runs out of “memory”, even though you may have plenty of free system memory……..this is what happened to me. Once it’s full and can’t log any more exceptions, JavaScript just stops working.

In order to correct this you need to first turn OFF the option to Log JavaScript Exceptions, then choose to Show [the] JavaScript Console window. Be patient! There could be hundreds of thousands of exceptions to load – I had nearly a million. Yes, that sounds like a huge number. It is. I had turned on Logging many many months ago, and then just forgot about it. You’d be surprised how many sites use JavaScript and that have tiny bugs in their code that cause exceptions – these get logged. The more you surf the web, the more JavaScript exceptions that will get logged.

You’ll notice a small button in the bottom left corner of the JavaScript Console window that says “Clear”. Click on it. You may have to repeat the procedure several times, as the Console will clear what it was able to load from the Log File, and then load up some more. Once your Log File is completely clear you can close the Console, and voila! Safari should now execute JavaScript as it should.

As an alternative you can manually delete entries using a text editor, but you cannot delete the Log File itself. Depending on your versions of Mac OS X and Safari, you might find this log file in different places – I found mine at: Macintosh HD/Library/Logs/Console/501/console.log. If you use a utility such as Cocktail to automatically delete Log Files you should be okay, but be sure to check your log files periodically to be sure they are staying cleaned up.

Once you have your Log File cleaned up, I recommend only using the Log JavaScript Exceptions feature when you need it to debug your own script, then keep it turned off when not in use. And definitely you should routinely clean up the Log File.

If you’re not familiar with the Debug Menu, it’s a hidden feature of Safari that opens up a large number of Advanced User/Developer functions (in addition the the logging already mentioned), such as the ability to change the browser’s User Agent, Showing the DOM Tree and View Tree, opening the current page in one of your other installed browsers, and much more. The Debug Menu is not for casual users, but if you can make use of these features, all it takes is a single command line in Terminal to add the Debug Menu to Safari. First, be SURE Safari is NOT running, then open Terminal and type:

% defaults write com.apple.Safari IncludeDebugMenu 1

That’s all there is. If you ever want it gone, just retype the same line with a 0 in place of the 1.

I hope you’ve found this helpful! Let me know if you’ve come up with a different solution – I’d love to know about it.

Kitten
Share with others:
Please Rate this Post:

posted in How To's | 3 Comments

28th August 2007

The Real Tech Kitten

So today I was called on to fix a a paper jam problem…….being the professional tech person that I am, I was able to fix it quickly…..it just takes a bit of kitten-know-how. 🙂

Kitten
Share with others:
Please Rate this Post:

posted in Funny Stuff | 0 Comments

Search: