[Javascript] problem with swfobject.js

Schalk Neethling schalk at volume4.com
Mon May 15 21:16:54 CDT 2006


Thank you very much Nick for the information.

Nick Fitzsimons wrote:
> Schalk wrote:
>> I am using swfobject.js to include flash on a website. Both IE and 
>> Firefox complains about the following snippet of code:
>>
>> if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){ 
>>
>> var n=(typeof _20=="string")?document.getElementById(_20):_20;
>> n.innerHTML=this.getSWFHTML();
>> return true;
>> }else{
>> if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}} 
>>
>> return false;}};
>>
>> In particular, it complains about the 'n' variable stating that it 
>> has no properties in FF and IE says Object expected. Has anyone else 
>> come across this problem? Any ideas on how to fix this? Thanks!
>>
>
> Well, I don't know the code you're using, but I know those errors. 
> They turn up because the variable named n (in this case) is being 
> assigned a reference to something that isn't there - which of course 
> means that it's referring to nothing at all. As whatever it's 
> referring to is non-existent (null, in this case), that thing has no 
> properties; when you try to access the properties of a non-existent 
> object via the property access operator ".", Firefox tells you the 
> thing before the property access operator "has no properties" (because 
> it's null), and IE tells you that it "expected" an "object" (rather 
> than null) whose properties it might access.
>
> The usual cause of something like this is that you have assigned a 
> reference to the variable named "n" but what you've assigned is 
> something that doesn't actually exist in the page. In this case the 
> code is assigning the value to the variable "n" that is the result of 
> the ternary expression:
>
> (typeof _20=="string")?document.getElementById(_20):_20
>
> This appears to be an unholy mess of code, but that's not the point; 
> let's just say that code written with an IE4 (1997) mindset, and then 
> patched to try to make it work properly on later and better browsers, 
> is often written very badly. It doesn't work in your document because 
> the document contains no element (by which I mean the DOM Level 1 
> definition of an Element) which has its "id" attribute set to the 
> value "_20". I can say this with absolute certainty even though I 
> haven't seen the document, because if the document contained an 
> element with the id "_20" then that element would be assigned to the 
> variable "n" and would have a (non-standard) innerHTML property, and 
> the code would work. If you had several elements which (incorrectly) 
> all had the id "_20" then the assignment would have produced a NodeSet 
> rather than null, and the error would be all about "does not support 
> this property or method" rather than "has no properties". It's worth 
> knowing about these differences in the kinds of errors produced in the 
> different cases as, although to a cursory glance they appear as opaque 
> as each other, there actually is useful information in those messages.
>
> As an aside, I would suggest that you be cautious about using code 
> that has abysmal naming conventions; it often causes more problems 
> than it solves. Good naming is a crucial part of good coding, and I 
> can't think of anything at all for which "_20" would be a good name. 
> (Well, apart from the newborn child of a Hollywood celebrity who's 
> trying to get some headlines.)
>
> Check your document and ensure that it has a relevant element with the 
> id attribute set to "_20" and it may well work - although it's a 
> wipeout for anybody with JS disabled or no Flash plugin. But you knew 
> that :-)
>
> HTH,
>
> Nick.

-- 
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
US Tel: (440) 499-5484
Fax: +27125468436
Web
email:schalk at volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_ at hotmail.com

We support OpenSource
Get Firefox!- The browser reloaded - http://www.mozilla.org/products/firefox/
 
The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error, please contact the sender and please delete all traces of this material from all devices.





More information about the Javascript mailing list