JavaScript issues in Opera 10

Hello,

I was wondering if anyone else has been experiencing JavaScript problems in Opera 10 (I use Windows XP).

The problems relate to the new HTML5 <canvas> tag. Opera supposedly supports <canvas> but has had problems rendering JavaScript relating to this tag. Examples of sites that Opera will not run properly:

http://www.blobsallad.se/

I would be grateful for any comments, particularly suggestions about how to get Pete Goodman’s script to run in Opera as his code is very useful to me. The script runs fine in Firefox, Safari and Chrome.

Thank you and regards,

Grant Bailey

Dear Tommy,
Many thanks for your reply.
Regards,
Grant Bailey

When using object detection, you need to make sure you test things in the right order.

if (document.addEventListener) {
    // code for standards-compliant browsers
} else if (document.attachEvent) {
    // code for IE
} else {
    // code for dinosaur browsers
}

If you want to exclude IE, you should make sure you’re not accidentally targeting Opera, too, since it supports some of IE’s non-standard stuff for compatibility reasons,

if (document.attachEvent && !window.opera) {
    // code for IE, but not Opera
}

Hello again,

I finally worked out the problem: Opera supports window.attachEvent, an Internet Explorer proprietary method. The script was using this method to filter out Internet Explorer. Opera was being inadvertently filtered out as well.

Suggestion: avoid using the window.attachEvent method to exclude IE if you want your scripts to appear in Opera!

Hope this helps.

Regards,

Grant Bailey

By way of update, the Blob Sallad script has been fixed. Any comments on why the other script does not work would be appreciated.
Regards,
Grant Bailey