SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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/

    http://www.petegoodman.com/labs/canvas-pie-timer/

    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

  2. #2
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  3. #3
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When using object detection, you need to make sure you test things in the right order.
    Code JavaScript:
    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,
    Code JavaScript:
    if (document.attachEvent && !window.opera) {
        // code for IE, but not Opera
    }
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Tommy,
    Many thanks for your reply.
    Regards,
    Grant Bailey


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •