PDA

View Full Version : alternative image when flash not detected


meerah
02-14-2006, 02:31 PM
Hi,
is there some simple code that tells browser to display alternative image when
visitor has not flash plugin installed on his computer ?

One more question...is it possible than to distinguish what type of flash content to show (streaming or not streaming) depending on connection speed...is it possible to get the bandwidth speed or should I better do it directly in flash (...more complicated).??

Cheers

domedia
02-14-2006, 02:38 PM
Have javascript write the flash tags, and then use noscript tags for alternative content.

davidj
02-14-2006, 02:49 PM
first create a...

<div id="flashid"></div>

this is where you want the flash to appear or an image if no flash is detected

now create the javascript detection script...

change these to suit
(check out the line where "place object tags here"
(check out the line where "place img tag here"

<SCRIPT LANGUAGE=JavaScript1.1>
<!--
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words[i])))
continue;
var MM_PluginVersion = words[i];
}
var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next \n');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {

document.getElementById('flashid').innerHTML = "place object tags here";

} else{

document.getElementById('flashid').innerHTML = "place img tag here";

}
//-->

</SCRIPT>

dthomsen8
02-14-2006, 03:01 PM
Thanks, I took that code, too.

meerah
02-14-2006, 04:08 PM
:lol: :lol: :lol:

meerah
02-15-2006, 11:31 AM
Hi theree....I cant force that script to work.. I am native to flash scripting and thought this might be familiar to me but it isnt ..can anybody help ?

I am sure it will be just something stupid but I have really weak knowledge of html and java programmig.

Cheers

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
[color=red][b]<SCRIPT LANGUAGE=JavaScript1.1>
<!--
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words[i])))
continue;
var MM_PluginVersion = words[i];
}
var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next \n');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {

document.getElementById('flashid').innerHTML = "streamBubbles.swf";

} else{

document.getElementById('flashid').innerHTML = "topPartTopBar copy.png";

}
//-->[/color]

</SCRIPT>[/b]
<style type="text/css">
<!--

div.wrapper {
margin-left : 10%;
margin-right : 10%;
}


-->
</style>
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x ; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function loader(){

window.frames['iframe1'].location.href="__vychoziPrislusenstvi.html";
window.frames['iframe2'].location.href="__vychoziStazeni.html";


}

//-->
</script>
</head>

<body onload="MM_preloadImages('_menu_prislusOver.png','_menu_vy robkyOver.png','_menu_firmaOver.png','_menu_aktual ityOver.png','_menu_keStazeniOver.png')">
<div class="wrapper">
<table width="782" height="615" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="227" rowspan="3" scope="col">leftPartTopBar copy.png</th>
[color=red][b]<div id="flashid"><th width="555" height="107" scope="col"></div></th>[/b][/color]
</tr>
<tr>
<td height="21" bordercolor="0">_menu_aktuality.png (#)[/url]_menu_firma.png (#)_menu_vyrobky.png (#)_menu_prislus.png (#) (#)_menu_keStazeni.png (#)[url="#"]_menu_leftBorder.png</td>
</tr>
<tr>
<td height="110" bordercolor="0"><iframe name="iframe1" width="556" marginwidth="0" height="110" marginheight="0" scrolling="auto" frameborder="0" id="content" ></iframe></td>
</tr>

<tr>
<td height="322" colspan="2" bordercolor="0"><iframe id="iframe2" name="iframe2" width="785" height="365" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
</table>


</p>

</div>

</body>
</html>

davidj
02-15-2006, 12:10 PM
where you have streamBubbles.swf you need to replace this with the entire object tags

test this first by just placing 2 different images in both conditions

meerah
02-15-2006, 05:43 PM
I have done it this way...hope Its all right

document.getElementById('flashid').innerHTML = "_menu_aktualityOver.png";

Dont have any basic knowledge of JavaScript...not sure whether I have to change some other parameters of that script to address that header frame..
..Do I have to insert something between the div tags ? Or is it inserted automatically via the flashid ?

davidj
02-16-2006, 08:36 AM
Do I have to insert something between the div tags
no just as they are is fine

where you have
"_menu_aktualityOver.png";
change one set of quotes to single quotes
'_menu_aktualityOver.png';

meerah
02-16-2006, 09:38 AM
I cant still force it to work....I have played for a while with that code and discovered that it works just when it is between body tags..BUT it should be in head tags , or not ?
No matter how it works..I trued to insert direct link to that .swf and it shows only alternative text and adds that classic flash script with plugion resource ....
Do I have to publish that flash or how to correctly link to that movie ????
Cheers so far :roll:

<SCRIPT LANGUAGE=JavaScript1.1>
<!--
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words[i])))
continue;
var MM_PluginVersion = words[i];
}
var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next \n');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {

document.getElementById('flashid').innerHTML = 'streamBubbles.swf" alt="firm" />'

} else{

document.getElementById('flashid').innerHTML = 'try_icon.gif'

}



<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="107">
<param name="movie" value="streamBubbles.swf" />
<param name="quality" value="high" />
<embed src="streamBubbles.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="107"></embed>
</object>
</p>
//-->

</SCRIPT>
</div>

</body>
</html>

davidj
02-16-2006, 09:44 AM
you could wrap it in a function and call it on an onLoad

if it works in the body then thats where you need to put it

you need to replace all image tag with <object tag which includes the flash file

meerah
02-16-2006, 10:04 AM
I have done it that way...but it still doesnt work..??

document.getElementById('flashid').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="107">
<param name="movie" value="streamBubbles.swf" />
<param name="quality" value="high" />
<embed src="streamBubbles.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="107"></embed>
</object>'

davidj
02-16-2006, 10:59 AM
i need to test this again

ill be back

chriskq
02-16-2006, 09:03 PM
your too nice DJ.

meerah
02-19-2006, 08:17 PM
Any clue ? Played with that code with no result.....

One more question .. is possible to make some image map on imported flash ? Some invisible button on separate layer or something like that .. I have no experience with layers so far so dont know..

davidj
02-20-2006, 11:53 AM
sorry for the delay with this

i have a problem at the moment coz i am moving house and have switched my internet connection off at my current address

i only get to view the forum while at work sneeking 10 mins here and there which is why i have been neglecting my duties on here for a while (sorry guys.. dom, CI)

i will be back upto speed on the heels of CI's post count in april once i get moved in to my new house

meerah
02-20-2006, 07:27 PM
Thanks so far David for your interest.

Anybody else knows how it all works ?