I am using swfobject (actually FlashObject 1.3c) to wrap flash that will be displayed on various publishers’ pages.
Recently, I noticed a bug in both IE and FF that says: “n has no properties; flashobject.js line 93”
The relevant code is: var n=(typeof _23=="string")?document.getElementById(_23):_23; n.innerHTML=this.getFlashHTML();
In my code that calls flashobject, I check to ensure that it is defined with ‘if (typeof FlashObject==”undefined”)’.
The problem is this: The publisher/partner on whose site the error occurs uses FlashObject as well, and I think that there is some sort of conflict taking place between my flashobject.js and their flashobject.js. My div id’s are all named uniquely, so that is not a problem. Does FlashObject check to see if it has already been loaded somewhere before doing anything?
Any suggestions? If the answer is “upgrade to 1.5”, is 1.5 fully backwards compatible to 1.3c (including calls to “new FlashObject()” instead of “new SWFObject()” for instatiation)?
the only major difference is the way the express install stuff works, so as long as you aren't using that, you'll be fine (And if you are, it's a pretty small change).
in 1.5 i included a fix that should stop the errors from happening if you include the swfobject.js script more than once, but it may not work right if you have two different versions (ie. you are using 1.5, and they are including 1.3).
but try it out anyway and let me know how it works out.
Geoff, I thought you might like to see more on this issue. Our use of SWFObject is for displaying flash ads on partner pages. Well, our partner had their own "FlashObject", causing a naming conflict. Here is the email I sent to them:
>>>>> Here is a detailed explanation of the problem, and a proposed solution.
There is a very popular open-source library call SWFObject for uniformly writing out the code necessary to display a flash (.swf) movie on a webpage. This library was called FlashObject in the past, but since “Flash” is a trademarked term, was renamed to SWFObject. However, backwards compatibility is maintained with the name “FlashObject.” Our ad server uses this library for displaying Flash creatives, and I know others do too (I saw the exact same javascript error in question being reported for some ads from the aolcdn.com domain). The origin of the error is that realsimple.com uses the name FlashObject to name a javascript object in this javascript file:
Around line 326 of this javascript file is where the FlashObject gets defined. Its definition is very similar to that of the open source library, so I suspect that this is a customized and trimmed down version of that library. So the problem is basically a naming conflict: An ad (such as ours) that includes the official SWFObject library will conflict with realsimple.com because both define a FlashObject javscript object. If realsimple.com used the library “as is”, this would not be a problem: The objects and methods of both of the libraries would be the same and everything would perform as expected.
However, realsimple.com’s FlashObject is different from the standard library. The relevant difference that causes the error is the difference between the FlashObject.write() methods. SWFObject’s “write” method expects the ID of a DOM object (or the DOM object itself) as a parameter, in which to write out the code to embed the flash movie. realsimple.com’s “write” method can take zero arguments. Therefore, if realsimple.com constructs a new FlashObject, and calls “write()” on that object, there could be an error because the referenced FlashObject may be an instance of the official SWFObject library, whose write method requires one argument. If this is the case, the error will be reported in the write method of the FlashObject source code. In our case, the error was reported to be within the “write” method of our swfobject.js file(as expected).
So what’s the solution? Javascript namespacing. realsimple.com should not use FlashObject as their object name as long as there is the ability for partners to display flash on their pages because the flash may be displayed using the official SWFObject (causing a naming conflict as we’ve seen). There are plenty of examples of javascript namespaces out there, but even calling it realsimple.FlashObject should suffice. Additionally, partners using the SWFObject library (such as ourselves) might remove the last line of the library which aliases the library object to the alias “FlashObject”, removing the likelihood of a naming conflict and requiring a more fully-qualified reference.
>>>>>
So I thought you might find interest in this Geoff. What are your thoughts on my proposed solution, and would you suggest anything else?
cool, since they are using 'flashobject' and not 'swfobject', you could also try removing the one line inside the swfobject script that assigns the var 'FlashObject = deconcept.SWFObject'
that way you won't be colliding with their variable anymore - just make sure you are using SWFObject and not FlashObject when you embed your swfs.