Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: RE: FLASH: Flash (javascript "OT") Question
From: Eric Dunham
Date: Thu, 10 Feb 2000 00:47:38 GMT

If I'm not mistaken, you should have to have to detect browser types to open
windows. I believe that NN and IE both use the same syntax for the
window.open() statement. Additionally, you shouldn't need to use the
'window' object if you're calling the script from within a simple set of
<script> tags in your document. In other words you shouldn't have to use
window.open(), you should just be able to use open().

Another word of advice when doing browser detection...don't use
navigator.appName because a lot of people, like myself, have changed the
code/response in our browsers to say something other than MSIE or Netscape
(mine says "Whatever"). A more reliable (and easily maintainable) method is
to use object detection. Let me explain...instead of using navigator.appName
== "MSIE" you could use if(document.all), and for NN you could use
document.layers. I don't really mean to get into a long rant on this, but I
think I might anyway, for the sake of explanation.

You see, for layers (<div> tags and such) IE uses the document.all object to
refer to them, and NN uses the document.layers object, so that becomes a
very easy way to differentiate browser classes instead of sniffing out the
appName. Furthermore, there are different browsers out there besides NN and
IE that might support the same object hierarchies that NN/IE do. For
example...NeoPlanet(I'm not sure if that changes the appName, though),
Opera, iCab, etc etc. And where X browser might support the same set of
objects that Y browser does, do you really want to have to sniff out each
and every .appName that's out there? I didn't think so.

Aside from the .appName issue, a lot of people also use scripts that are
dependent upon versions of the different browser platforms that are out
there (I'm sure you've seen the parseInt(navigator.appVersion) code
somewhere out there :) So, not only does using object detection eliminate
that (ie. testing for document.all will encompass both IE4x/IE5x) tedious
coding, it also allows for forwards compatibility. If you did have a
detection script that needed to be able to detect .appVersion to point the
user to an appropriate page (based on version for JS/CSS compatibility,
etc.) what happens when someone comes in using IE5.5 Beta, or if they have
(successfully :P compiled the Mozilla source code? Both of those browsers
should be more than capable of displaying whatever script you throw at them,
but when you detect .appVersion and it doesn't match your code, do you just
shunt them off to a text-only page because you accidentally thought they
were using Lynx? I didn't think so again either.

So all in all, I've found it less frutrating to test for objects rather than
.appName/.appVersion because IMO it's more reliable and it's not near as
tedious. As an example:
<code>
//The following sets up boolean variables
//based on object detection (or lack thereof).
//I have used nn for Netscape (the major browser supporting
document.layers),
//ie for Internet Explorer (the major browser supporting document.all)
//and ot_JS for other browsers (Java-Enabled)
//keep in mind that you should be able to use the navigator.javaEnabled()
//method on NN and IE as well.
//I haven't tried to see what the result is if you turn off JS manually
//but you can :)
//Anyway...
nn = (document.layers)? true:false;
ie = (document.all)? true:false;
if (!ie && !nn) ot_JS = navigator.javaEnabled();
</code>
It's a very simple bit of code (and I know that there are more comments than
code :)
And now you have boolean variables that hold true or false values based on
the objects/methods that were supported by the browser.
If you want to put that inside some <script> tags, you might also try using
document.write() or alert() statements so that you can see the values of the
variables. Have fun!

HTH,
Eric Dunham

<snip>
Just a quick javascript question (from the jscript challenged) as related to
a browser sniffer displaying fullscreen swf files.
While recognizing which browser is which. I want to open a full screen .swf.

So if I use:

if (navigator.appName=="Microsoft Internet Explorer")
{
window.open("my.swf","screen","fullscreen=yes");
}

And it works great. What do I use for NN?

{
if (navigator.appName=="Netscape")
{
what.the("heck goes here?")
}
</snip>


flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flashforward2000 and The Flash Film Festival
"The World’s Premier Flash Solutions Conference and Expo"
March 27-29, Nob Hill Masonic Center, San Francisco, California

-Register before Feb 25 and save $200!!-- www.flashforward2000.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpatchinwag [dot] com


Replies
  FLASH: Flash (javascript "OT") Question, Jeff Bradshaw

[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]