...

View Full Version : Alternative content for non-flash



L3EOO
07-26-2010, 03:46 PM
I have this code http://www.jsfiddle.net/Nntc7/ created by a pdf publisher, I need to offer non flash content to users but dont know javascript and I cant get the thing to work using swfobject, How do I edit this to allow for alternative content??

thanks in advance

L3EOO
07-26-2010, 04:25 PM
and here is the code


<script language="JavaScript" type="text/javascript">

function getURLParam(strParamName){
var strReturn = "";
var strHref = window.location.href;
if ( strHref.indexOf("?") > -1 ){
var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
var aQueryString = strQueryString.split("&");
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
if (
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
break;
}
}
}
return unescape(strReturn);
}

document.write(
'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n'+
' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"\n'+
' WIDTH="100%" HEIGHT="100%" id="flashMovie" align="middle">\n'+
' <PARAM NAME="allowScriptAccess" value="sameDomain" />\n'+
' <PARAM NAME="allowFullScreen" value="true" />\n'+
' <PARAM NAME=movie '+
' VALUE="flippingbook.swf?pageNumber='+getURLParam('pageNumber')+'" />\n'+
' <PARAM NAME=quality VALUE=high />\n'+
' <PARAM NAME=bgcolor VALUE=#ffffff />\n'+
' <PARAM NAME=scale VALUE=noscale />\n'+
' <EMBED src="flippingbook.swf?pageNumber=' + getURLParam('pageNumber') + '"' +
' bgcolor=#ffffff WIDTH="100%" HEIGHT="100% '+
' quality="high"' +
' scale="noscale"' +
' name="flashMovie"' +
' allowFullScreen="true"' +
' TYPE="application/x-shockwave-flash"'+
' />\n'+
'</OBJECT>\n');
</script>

VIPStephan
07-26-2010, 05:01 PM
You should look into the principle of progressive enhancement (http://en.wikipedia.org/wiki/Progressive_enhancement). PE means in your context that you provide your “alternative content” as default content and then replace that content with Flash if JS is available. This is also how the dynamic publishing method of SWFObject works. You have a plain old HTML container with the plain old HTML content and then you make SWFObject replace that HTML container with the Flash object.

In the JS code that program gave you this is the part that writes the HTML for the Flash object:


document.write(
'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n'+
' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"\n'+
' WIDTH="100%" HEIGHT="100%" id="flashMovie" align="middle">\n'+
' <PARAM NAME="allowScriptAccess" value="sameDomain" />\n'+
' <PARAM NAME="allowFullScreen" value="true" />\n'+
' <PARAM NAME=movie '+
' VALUE="flippingbook.swf?pageNumber='+getURLParam('pageNumber')+'" />\n'+
' <PARAM NAME=quality VALUE=high />\n'+
' <PARAM NAME=bgcolor VALUE=#ffffff />\n'+
' <PARAM NAME=scale VALUE=noscale />\n'+
' <EMBED src="flippingbook.swf?pageNumber=' + getURLParam('pageNumber') + '"' +
' bgcolor=#ffffff WIDTH="100%" HEIGHT="100% '+
' quality="high"' +
' scale="noscale"' +
' name="flashMovie"' +
' allowFullScreen="true"' +
' TYPE="application/x-shockwave-flash"'+
' />\n'+
'</OBJECT>\n');


Now you just have to extract the plain HTML which comes down to this:

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" WIDTH="100%" HEIGHT="100%" id="flashMovie" align="middle">
<PARAM NAME="allowScriptAccess" value="sameDomain" />
<PARAM NAME="allowFullScreen" value="true" />
<PARAM NAME=movie VALUE="flippingbook.swf?pageNumber='+getURLParam('pageNumber')+'" />
<PARAM NAME=quality VALUE=high />
<PARAM NAME=bgcolor VALUE=#ffffff />
<PARAM NAME=scale VALUE=noscale />
</OBJECT>

… and replace it with SWFObject. There is an elaborate documentation about how to implement it on their website. But note that you have that getURLParam() function in your JS code, too, which is used in that one param element. You probably need to include that in your page so the correct URL parameters are created.

Kor
07-26-2010, 05:08 PM
Hm. My question would be: alternative at Flash content for who? For the users who have no Flash plug-in installed? For the users who have Flash blocker installed and active? For the users who have javascript disabled (and the Flash is run trough a javascript code)?

L3EOO
07-27-2010, 06:28 PM
thanks VIPStephan got it working you made me think about the code in a new way and then the resolution was obvious.

thanks
Lee



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum