[Javascript] flash on mac and javascript [again]
Nick Fitzsimons
nick at nickfitz.co.uk
Wed Apr 12 14:19:10 CDT 2006
Schalk wrote:
> Please have a look at the following page: www.tele-court.com. If you
> view this on a PC you will see that it has a Flash header however, when
> viewed on Mac using Safari the Flash header does not show. I use the
> following JavaScript to load the Flash header:
It doesn't work on Opera either (7.5/Mac, 8.54/Win), nor on IE/Mac (5.2).
The first problem is with the lines:
> window.onload = header_wsound_object;
> window.onload = header_wsound;
>
I'm not sure what you're trying to do here, but it looks like you want
both functions to execute onload. What is actually happening is that you
set the onload handler to a reference to the function
"header_wsound_object", but then immediately replace that with a
reference to the function "header_wsound". Thus, once the page has fully
loaded, "header_wsound" is executed (by all browsers), and
"header_wsound_object" is never called at all.
"header_wsound" attempts to insert an <embed> element to hold the Flash
object. <embed> has never been part of any standard - it was introduced
with Netscape 3 (or 2 even?) back in 1996, and has only ever been
supported for legacy reasons by Netscape <= 4, Mozilla/Firefox, and
IE/Windows (note that IE/Win and IE/Mac are two completely differet
browsers).
Virtually every modern browser understands <object> so, unless users of
Netscape 4 and older are important to you, you should look for a
technique which allows you to use standards-based markup. You could just
get rid of "header_wsound" and its assignation to the onload handler and
then all browsers would use the <object> version; however the problem
you then have is that IE/Win implements <object> incorrectly - or, to
avoid religious wars, differently from other browsers.
You can find more information about getting <object> working
cross-browser in Drew McLellan's excellent A List Apart article "Flash
Satay":
<http://www.alistapart.com/articles/flashsatay/>
An example of object-only markup that I've used with success for a
couple of years is:
<object height="234"
width="468"
type="application/x-shockwave-flash"
id="flashPlayer"
data="yourFlash.swf">
<param name="movie" value="yourFlash.swf">
<param value="high" name="quality">
<param value="opaque" name="wmode">
<param value="firstParam=blah&secondParam=bleh" name="FlashVars">
<!-- optional fallback markup -->
<div id="fallback">
<p>
This markup should be displayed when the
Flash Player is missing.
</p>
<p>
You can replace it with a suitable image, or any HTML you like
and it only gets displayed if the user hasn't installed Flash.
</p>
<p>
Some browsers have trouble with this however...
test as necessary.
</p>
</div>
<!-- end of fallback markup -->
</object>
You already have the basic code for creating and inserting the <object>
element, so try modifying it to generate the above structure (no need to
include the comments, and the fallback code is optional) and see what
happens :-)
BTW, if you did execute both functions onload, browsers like IE/Win and
Firefox would end up understanding both the <object> and the <embed> and
would show the Flash twice.
Hope this helps,
Nick.
--
Nick Fitzsimons
http://www.nickfitz.co.uk/
More information about the Javascript
mailing list