| |||||||||||
| |||||||||||
Sensing whether Flash is available on a browser
this example from a Well House Consultants training course
Source code: isflash.html Module: W611
<html>
<!--
# Just comments for our automated script cataloguer!
-->
<head><title>Is Flash installed, and what version?</title></head>
<SCRIPT LANGUAGE="Javascript">
<!--
// Altered from http://www.quirksmode.org/js/flash.html (with thanks!)
// Erring on the side of caution, though, and taking out the Vb bit!
// Return 2 for YES, 1 for NO and 0 for "dunno" in flashinstalled
var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
x = navigator.plugins["Shockwave Flash"];
if (x)
{
flashinstalled = 2;
if (x.description)
{
y = x.description;
flashversion = y.charAt(y.indexOf('.')-1);
}
}
else
flashinstalled = 1;
if (navigator.plugins["Shockwave Flash 2.0"])
{
flashinstalled = 2;
flashversion = 2;
}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
x = navigator.mimeTypes['application/x-shockwave-flash'];
if (x && x.enabledPlugin)
flashinstalled = 2;
else
flashinstalled = 1;
}
else
MSDetect = "true";
// And go on here to use VB Script ...
// -->
</SCRIPT>
<body>
It's great to use current and new technologies on your web site, but you want
to be able to suppot older browsers and more cautious users too; not everyone
has Flash, so you have to compromise? Not really - you CAN sense whether or
not Flash is loaded onto a browser ... and call up alteratives (different links
and different images, for example) depending on what you find.<br><br>
<b>This demonstration tells you whether or not the Flash plugin is installed
on your browser.</b><br>
<SCRIPT LANGUAGE="Javascript">
<!--
document.write('Flash Status is '+flashinstalled+'<br>');
if (flashinstalled == 2)
document.write('i.e. you do have Flash<br>');
if (flashinstalled == 2)
document.write('and it is version '+flashversion+'<br>');
if (flashinstalled == 1)
document.write('i.e. you do NOT have Flash<br>');
if (flashinstalled == 0)
document.write('i.e. you MAY have Flash<br>');
// -->
</SCRIPT>
<br>Result of test should be above. You will not see any result at all
if you do not have JavaScript!<hr />
Now let's call up a static image if we're unsure of our Flash, or a flash
movie if we know we can (later that version 6)!<br><br>
<SCRIPT LANGUAGE="Javascript">
<!--
function writeOneScreen(sURL){
document.write('<object '+
'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
'codebase="https://download.macromedia.com/pub/shockwave'+
'/cabs/flash/swflash.cab#version=7,0,0,0" '+
'WIDTH="344" HEIGHT="280" id="onescreen" ALIGN="">');
document.write('<param name=movie value="' + sURL + '">');
document.write('<param name=quality value=high>');
document.write('<param name=bgcolor value=000000>');
document.write('<embed src="' + sURL + '" bgcolor=000000 '+
'quality=high NAME="onescreen" ALIGN="" '+
'TYPE="application/x-shockwave-flash" '+
'PLUGINSPAGE="https://www.macromedia.com/go/getflashplayer" '+
'WIDTH="344" HEIGHT="280">');
document.write('</embed>');
document.write('</object>');
}
if (flashinstalled == 2 && flashversion > 6) {
writeOneScreen('whmpicshow.swf?languageid=1');
} else {
document.write(
'<img src=http://www.wellhousemanor.co.uk/images/WHMext.jpg>');
}
// -->
</SCRIPT>
<br> And a link which will differ depending on whether
or not we have Flash<br>
<SCRIPT LANGUAGE="Javascript">
<!--
if (flashinstalled == 2 && flashversion > 6) {
document.write('<a href=http://www.wellho.net/course/index.html>'+
'A course index since you have flash</a>');
} else {
document.write('<a href=http://www.wellho.net/index.html>'+
'Our home page without flash</a>');
}
// -->
</SCRIPT>
</body>
</html>
Learn about this subject
This module and example are covered as required on private courses.
Should you wish to cover this example and associated subjects, and you're attending a public course
to cover other topics with us, please see our extra topic program.
Books covering this topic
Yes. We have over 700 books in our library. Books
covering are listed here and when you've selected a
relevant book we'll link you on to Amazon to order.
Other Examples
This example comes from our "this" training module. You'll find a description of the topic and some
other closely related examples on the "this" module index page.
Full description of the source code
You can learn more about this example on the training courses listed on this page,
on which you'll be given a full set of training notes.
Many other training modules are available for download (for limited use) from our download centre under an Open Training Notes License. Other resources
• Our Solutions centre provides a number of longer technical articles.
• Our Opentalk forum archive provides a question and answer centre. • The Horse's mouth provides a daily tip or thought. • Further resources are available via the resources centre. • All of these resources can be searched through through our search engine • And there's a global index here. Purpose of this website
This is a sample program, class demonstration or answer from a
training course. It's main purpose
is to provide an after-course service to customers who have attended our
public private or
on site courses, but the examples are made
generally available under conditions described below.
Web site author
Conditions of use
Past attendees on our training courses are welcome to use individual
examples in the course of their programming, but must check
the examples they use to ensure that they are suitable for their
job. Remember that some of our examples show you how not to do
things - check in your notes. Well House Consultants take no responsibility
for the suitability of these example programs to customer's needs.
This program is copyright Well House Consultants Ltd. You are forbidden from using it for running your own training courses without our prior written permission. See our page on courseware provision for more details. Any of our images within this code may NOT be reused on a public URL without our prior permission. For Bona Fide personal use, we will often grant you permission provided that you provide a link back. Commercial use on a website will incur a license fee for each image used - details on request. |
| ||||||||||
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho PAGE: http://www.wellho.net/resources/ex.php • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb |