Does anyone have an example of script that can work reliably well across IE/Firefox to detect if the browser is capable of displaying embedded flash content. I say reliably because I know its not possible 100% of the time.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
I agree with Max Stewart. SWFObject is the way to go. I'd like to supplement his answer with a code example. This ought to to get you started:
Make sure you have included the
swfobject.js
file (get it here):Then use it like so:
Replace "9.0.115" with whatever minimum flash version you need. I chose 9.0.115 as an example because that's the version that added h.264 support.
If the visitor does not have flash, it will report a flash version of "0.0.0", so if you just want to know if they have flash at all, use:
View the source at http://whatsmy.browsersize.com (lines 14-120).
Here is the abstracted cross browser code on jsbin for flash detection only, works on: FF/IE/Safari/Opera/Chrome.
what about:
If you are interested in a pure Javascript solution, here is the one that I copy from Brett:
Code for one liner
isFlashExists
variable:Note that there is an alternative like this:
swfobject.getFlashPlayerVersion();
Have created a small
.swf
which redirects. If the browser is flash enabled it will redirect.