techsd / swfobject

Automatically exported from code.google.com/p/swfobject
0 stars 0 forks source link

SWF Object don't work on Google Chrone #175

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. SWF Object don't work on Google Chrone

What is the expected output? What do you see instead?

Uncaught TypeError: Cannot call method 'appendChild' of undefined 
http://xxx/xxx/js/swfobject.js (line 5)

What version of the product are you using? On what operating system?

SWFObject v2.1

Please provide any additional information below.

Original issue reported on code.google.com by pasmanik on 23 Sep 2008 at 8:07

GoogleCodeExporter commented 9 years ago
Google Chrome is still in an early beta phase, so please do submit your bugs to 
the
Google team.

We will keep an eye on the project as it evolves.

Original comment by bobbyvandersluis on 23 Sep 2008 at 3:00

GoogleCodeExporter commented 9 years ago
Today I've run the SWFObject 2.1 test suite through Goggle Chrome 0.2.149.30 on 
Win
XP SP3 and all tests passed. 

I have also ran the Flash embed test suite (object + embed only) though it and
concluded that it behaves just like recent Webkit engines.

Original comment by bobbyvandersluis on 17 Oct 2008 at 11:27

GoogleCodeExporter commented 9 years ago
I also found this problem and I think tracked it down.  I created a minimal 
test page 
without a "head" tag and it failed.  Adding the <head></head> fixed it.

The problem is in this source code:

    /* Cross-browser dynamic CSS creation
        - Based on Bobby van der Sluis' solution: 
http://www.bobbyvandersluis.com/articles/dynamicCSS.php
    */  
    function createCSS(sel, decl) {
        if (ua.ie && ua.mac) {
            return;
        }
        var h = doc.getElementsByTagName("head")[0], s = 
createElement("style");
        s.setAttribute("type", "text/css");
        s.setAttribute("media", "screen");
        if (!(ua.ie && ua.win) && typeof doc.createTextNode != UNDEF) {
            s.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
        }
        h.appendChild(s);
        if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && 
doc.styleSheets.length > 0) {
            var ls = doc.styleSheets[doc.styleSheets.length - 1];
            if (typeof ls.addRule == OBJECT) {
                ls.addRule(sel, decl);
            }
        }
    }

Evidently, whereas in Firefox and IE 

doc.getElementsByTagName("head")[0]

returns something reasonable when there is no head, in Chrome it returns null.

I realize that this may be nonstandard, but it should be simple to fix.

m

Original comment by marc.lu...@gmail.com on 5 Feb 2009 at 10:20

GoogleCodeExporter commented 9 years ago
Please red issue report 222: 
http://code.google.com/p/swfobject/issues/detail?id=222

Note that Google Chrome also use Webkit just like Safari

Original comment by bobbyvandersluis on 5 Feb 2009 at 10:58

GoogleCodeExporter commented 9 years ago
I found a simple solution for this.
It seems that chrome loads external javascript asynchrnously.
So at the time swfoject is invoked, "swfobject" in NULL.

Solution: add a line before the swfobect line:

while (!swfobject) {}

and it works :)

Original comment by zibree on 24 Jul 2009 at 8:24