me like :-)
On Jan 21, 8:48 pm, Philip Hutchison <[email protected]> wrote:
> Hi guys
>
> Here's a shorter way to accomplish the same task:
>
> function getSwfObjectVersion(){
> return (window.swfobject) ? 2 : (window.SWFObject) ? 1 : false;
>
> }
>
> window.onload = function(){
> alert(getSwfObjectVersion());
>
> };
>
> (Demos are
> online:http://pipwerks.com/lab/swfobject/version-detection/index.html)
>
> This function works by checking the global window object for the existence
> of objects named swfobject and SWFObject. There are three things going on
> here:
>
> 1. Since we're checking (window.swfobject) and not just (swfobject), the
> browser won't throw a "swfobject is undefined" error if swfobject isn't
> found. This means no need for the !== null syntax.
>
> 2. Since JavaScript is case-sensitive, two objects with the same name but
> different case will appear as two unique objects. SWFObject 1.x was written
> with uppercase SWFO, while SWFObject 2.x is written with all lowercase
> letters.
>
> 3. In the event both versions are found, the function returns SWFObject 2,
> which is the preferred version.
> Hope you like. :)
> - philip
>
> On Wed, Jan 21, 2009 at 3:47 AM, Aran Rhee <[email protected]> wrote:
>
> > Bobby.
>
> > Re: being dirty - I don't know, it just felt a bit wrong to be doing
> > checking in this way. I guess I am used to having a version static I can
> > get
> > to :) (Flash components / frameworks etc)
>
> > Unfortunately your code below throws an error: 'deconcept' is undefined, if
> > you try using a swfobject.js != 1.x.
>
> > V 0.3:
>
> > <script type="text/javascript">
> > function swfobjectVersionTest()
> > {
> > if (typeof deconcept=='object' && deconcept!=null) { return
> > 1; }
> > else if (typeof swfobject=='object' && swfobject!=null) {
> > return 2; }
> > else { return 0; }
> > }
>
> > var v = swfobjectVersionTest();
> > alert(v);
> > </script>
>
> > Aran
>
> > -----Original Message-----
> > From: [email protected] [mailto:[email protected]] On
> > Behalf Of Bobby
> > Sent: Wednesday, 21 January 2009 10:18 PM
> > To: SWFObject
> > Subject: Re: which version of swf object is being used
>
> > Web authors usually know which version they code against, so checking
> > if the namespace/object exist looks fine to me (why is it dirty any
> > way?)
>
> > Just remember that typeof null also returns 'object', so you could may
> > better check for:
>
> > <script type="text/javascript">
> > function swfobjectVersionTest() {
> > if (deconcept) { return 1; }
> > else if (swfobject) { return 2; }
> > else { return 0; }
> > }
> > var v = swfobjectVersionTest();
> > alert(v);
> > </script>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SWFObject" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/swfobject?hl=en
-~----------~----~----~----~------~----~------~--~---