JavaScript weirdness: “ReferenceError XXX is not defined”

If you’re getting a “ReferenceError XXX is not defined”-error while calling JavaScript functions (which definitive exist), you might want to check for any for each(…) – constructs in your source.
In case you use this way of iterating through a sequence, the browser will disrupt parsing parts of your JavaScript code, which leads to the error message above, if you use a different browser than Firefox.

I was bangin my head for the past 3 hours against my desk just to find out that the for each-expression only exists in Firefox (seems be some proprietary implementation) but not in all other browsers like Safari, Chrome etc…

So, in case you have something like this:

for each (var item in myArray){
   doSomething(item);
}

…you might want to replace it with this:

for (var i=0; i<myArray.length; i++){
   var item = myArray[i];
   doSomething(item);
}

One more thing: This won’t have to be the cause for your problems. Many JavaScript engines simply abort executing your code without any further notification on many kind of errors. The above solution is just one of the many, many cases that can lead to this kinda problems, but since it’s such a nasty one, I thought it would be worth to post it here.

God, this is one of the reasons why I dun really like JavaScript that much.. Every browser manufacturer cooks his own soup..

Tip: If you have troubles running a JavaScript program that runs on Firefox, but not on other browsers, you can try using Google Chrome, which has a quite decent JavaScript debugger built-in. To open just hit alt+cmd+J (on Mac OS).

Duffman loves Duff

Guess, what I found today at one of our gas stations… Yeah, right:

The legendary DUFF

But it’s brewed in Germany. Weird, eh?

Ich hab’s doch immer gewusst..

Frauen können nicht einparken. Jetzt sogar wissenschaftlich nachgewiesen:

Die Frauen brauchten im Durchschnitt 20 Sekunden länger als die Männer. Die Zeit nutzten sie jedoch nicht zum Einnnehmen einer optimalen Parkposition, sondern standen vielmehr am Ende meistens deutlich schiefer als die Fahrer. Die Biopsychologin Dr. Claudia Wolf, eine der Autorinnen der Studie, glaubt, dass Frauen grundsätzlich eine geringe Risikobereitschaft haben und deshalb vorsichtiger einparken. Warum sie trotzdem so schief stehen, könne sie jedoch nicht erklären, sagte sie dem “Daily Telegraph”. Allerdings gehe es, “nur ums Parken, nicht um den Triumph der Männer über die Frauen.”

Quelle: tagesschau.de

Object inspector for JavaScript

Sometimes, one cannot inspect JavaScript-objects using an external debugger, like Firebug.

For example, this can happen during development of Firefox addons: Open the JavaScript inspector of Firebug and you will only see the JavaScript errors on the currently displayed website, but not the ones from the addon.

Thus, I modified the inspect()-function from Ariel Tapia (codeprojects.com) a bit. My version will not only return a HTML string with all the attributes and functions that are inside the object. It will also add the values of these.

Installation: Just unzip the file and include it via
<script src="inspector.js" type="text/javascript"></script>
(As an alternative, you can also just copy and paste the function directly into your source.)

Example usage: var htmlResult = inspect(myObject, null, null);
htmlResult will now hold a string-representation of the properties and functions of myObject.

Note: An alternative for Firefox addons is Venkman. Haven’t really figured out how to use that though.
So, if you don’t want to bother with Venkman or need an object-inspector for any other purpose, I think you’ll be fine with my function provided above.

Mozilla guys are real geeks

I am currently playing around a bit with Firefox addons.
To create a GUI for such extensions you need XUL, a XML-based markup language.

Now, check out the namespace for XUL:
http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul

Don’t get it? Fool! Go watch Ghostbusters I again! (Man, this reminds me of me being a kid and watching this movie over and over again).

However, now guess how a Firefox addon is called for debugging JavaScript in such extensions. Right: Venkman

Google Chrome’s real purpose

I thought Chrome was made for rendering HTML. Seems like, I was wrong.
This is what happened to me some minutes ago:

Chrome cannot render HTML
English translation: The document “test.html” could not be opened. Chrome cannot open “HTML document” type files.

Nice.

This happens if I try to drag a HTML document from my desktop onto the Chrome icon on my dick dock.
If I now press CMD+O and select the same file, Chrome renders the page wonderfully.

I hope this gets fixed in the final release. Using the 4.0.249.43 Beta for Mac OS X here.

Update: I just tried again with another HTML file. Worked. Tried again with the same file. Fail. What the heck?

Update II : I just tried to undo a typo in the Wordpress 2.9 WYSIWYG editor in Google Chrome. Doesn’t work. Jeez…

Where is my head?

My girlfriend sometimes says that I’m thinking to much.

Maybe she’s right and I should stop that or I’ll loose something more important than my keys one day..

Keys in Fridge

Fresh keys

Fruit-RSS: A Safari-style feed subscription extension for Google Chrome and Mozilla Firefox

Fruit-RSS is a simple extension that ads (Apple) Safari-style feed subscription capability to Google Chrome and Mozilla Firefox. It lets you subscribe to RSS and Atom feeds without having to register at online subscription services like Google Reader.

The look and feel is very similar to Apple’s Safari browser. Check out the screenshot and you’ll know what I mean, if you know how Safari displays feeds.
Another nice feature is that it checks for new feed updates at regular intervals and marks those feeds that have new postings in there. Bookmarks that point to a Fruit-RSS feed which was updated will have a mark like this:

Fruit-RSS feed marker

Return top
Original theme by monolab. Modified by Timo Ernst.