By: Janus Boye
There are some apparent flaws in the Opera 3.x browser, related to the JavaScript interpreter.
To help you get around these, we have made a list of Opera Compatible JavaScript Articles. These are the articles that we have tested, and found to work in Opera 3.1+
If you find a work-around please let us know, so we can update the pages.
If you've had any problems getting a browser detect script to work in Opera, we also have a Opera compatible browser detect script ready for use:
Many poorly designed browser detect scripts, have proven to detect Opera as Netscape Navigator 3. This has been the cause of many worries, as Opera 3.x doesn't exactly support the same things as the old Netscape Navigator 3.
The browser detect script below, will direct Netscape Navigator and Microsoft Internet Explorer users to a different page.
<script language="JavaScript"><!-- UserAgent = navigator.userAgent AgentName = UserAgent.substring(25,30) if (AgentName != "Opera") { window.location.href="index.htm" } //--></script> |
In version 3.x of the Opera browser, there has been some problems discovered with mathematical computations. Math.round (1.2) will for example give you 2!. To learn more on Math in JavaScript, you can read the Math functions in JavaScript article.
The date object can also cause some problems, as this is implemented differently than in, for example, Netscape 3. Since most of the constructor formats for the Date object fails to properly create and initialize a Date object, most articles that use the Date object are incompatible.
It seems that Opera 3.x is having problems with the with statement, especially inside forms.
In the script below, we have a form with two input areas. In JavaScript we then try to write the values of each input area, plus the length.
In IE and NN the script works nicely, as the document.write, gives us a length of 2 and test1.value: one and test2.value: not two.
Opera 3.x reports the length as null, but gets the other values correct.
<form name="testForm"> <input type="input" value="one" name="test1"> <input type="input" value="two" name="test2"> </form> <script language="JavaScript"><!-- with (document.testForm) { document.write('length: ' + length + ' |
The following shows the above example in action:
In NN and IE, JavaScript should write the following:
length: 2
test1.value: one
test2.value: not two
In Opera 3.x, you should instead see the following:
length: null
test1.value: one
test2.value: not two
Last, but not least, using radio buttons with JavaScript in Opera, have also been reported to cause some problems. In version 3.1 JavaScript falsely reports radio buttons as checked, and setting a radio button with JavaScript does not unselect other buttons in the same group. The article: Check Boxes and Radio Buttons, is a nice example of this problem.
View the profile on Janus Boye