Dating Sim Now Works in Firefox

So someone sent me a fix for my Dating Simulator so it will work on Firefox. I tested it, and it works.

Here is the problem in a nutshell:

In most programming languages, there are two kinds of subroutines: functions and procedures. In javascript, its all functions. The difference being that functions can return a value of some sort. Well because there are no procedures in javascript, I use functions as if they were procedures (so does everybody), so I do not return any value at all.

In IE, Opera, and Safari, if there is no return statement, it assumes the function is false and just moves on.
In Firefox, if there is no return statement, it assumes the function is true.

So with an html code like:
<a href=”#” ONCLICK=”parent.footer.choice1()” title=”try this”> IE etc, just execute the onclick command no questions asked.
Firefox executes the onclick, then (because the function is “true”) executes the anchor link # as well, which does not exist so the page gets refreshed instead, and the simulation is stumped!

I can’t remove the href, because IE will get stumped

So the fix is to change every onclick as follows:
<a href=”#” ONCLICK=”parent.footer.choice1();return false;” title=”try this”>
now it executes correctly in all browsers.

Now who is right, IE/Opera/Safari or Firefox/Mozilla?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s