Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Javascript to detect the Flash plugin

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,
We are trying to use Javascript to detect if the Flash plugin is installed on the client browser. If the plugin is installed we show a flash animation, if not we display a .gif image.
We can't figure out what is wrong with our code, here is part of the code and the error message that we get from the server:
Thanks in advance for your help.
Francis

code:

Code:
<!--- Condition to manage the display of the proper banner, the season banner will
only appear on the welcome page after the user has logged on. --->
	<cfif session.showSeasonGreetingsBanner IS true>
<SCRIPT LANGUAGE=&quot;Javascript&quot;>
var flashinstalled = 0;
MSDetect = &quot;false&quot;;
if (navigator.mimeTypes && navigator.mimeTypes.length)
{
x = navigator.mimeTypes['application/x-shockwave-flash'];
if (x && x.enabledPlugin) flashinstalled = 2;
else flashinstalled = 1;
}
else
{
MSDetect = &quot;true&quot;;
}
</SCRIPT>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>
on error resume next
If MSDetect = &quot;true&quot; Then
If Not(IsObject(CreateObject(&quot;ShockwaveFlash.ShockwaveFlash&quot;))) Then
flashinstalled = 1
Else
flashinstalled = 2
End If
End If
</SCRIPT>
<cfif IsDefined(&quot;flashinstalled&quot;) AND flashinstalled IS 2>
<cfset banner = &quot;flash&quot;>
<cfset session.showSeasonGreetingsBanner = false>
<cfelseif>
<cfset banner = &quot;christmas_banner.gif&quot;>
<cfset session.showSeasonGreetingsBanner = false>
</cfif>
	<cfelse>
<cfset banner = &quot;top_banner.gif&quot;>
	</cfif>
<cfif banner IS &quot;flash&quot;>
<OBJECT classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;
 <!-- this is line 228 --> codebase=&quot;[URL unfurl="true"]http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0&quot;[/URL]
ID=christmas_banner WIDTH=434 HEIGHT=30>
<PARAM NAME=movie VALUE=&quot;christmas_banner.swf&quot;> <PARAM NAME=loop VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src=&quot;/morceaux/christmas_banner.swf&quot; loop=false quality=high bgcolor=#FFFFFFWIDTH=434 HEIGHT=30 TYPE=&quot;application/x-shockwave-flash&quot; PLUGINSPAGE=&quot;[URL unfurl="true"]http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&quot;></EMBED>[/URL]
</OBJECT>
<cfelse>
<td align=&quot;right&quot; valign=&quot;bottom&quot; width=&quot;#Int(pageWidth - 216)#&quot;><h3>#PageTitle#</h3><img src=&quot;/morceaux/#banner#&quot; width=&quot;#Int(pageWidth - 216)#&quot; height=&quot;30&quot; vspace=&quot;0&quot; hspace=&quot;0&quot;></td>
</cfif>

and the error message:
Error Occurred While Processing Request
Error Diagnostic Information
Just in time compilation error
Invalid parser construct found on line 228 at position 78. ColdFusion was looking at the following text:
=
Invalid expression format. The usual cause is an error in the expression structure.
The last successfully parsed CFML construct was static text occupying document position (226:29) to (228:69).
The specific sequence of files included or processed is:
/data/webdata/docs-443/logout.cfm
/data/webdata/docs-443/global_includes/visual_header.cfmCFInclude
The error occurred while processing an element with a general identifier of (CFINCLUDE), occupying document position (6:1) to (6:55) in the template file
/data/webdata/docs-443/logout.cfm.
Date/Time: Tue Dec 05 15:11:08 2000
Browser: Mozilla/4.7 [en]C-CCK-MCD (WinNT; U)
Remote Address: 192.75.88.40
HTTP Referer: Query String: message=logout
Execution Time
133 milliseconds
1 ms
/DATA/WEBDATA/DOCS-443/APPLICATION.CFM
130 ms
/DATA/WEBDATA/DOCS-443/LOGOUT.CFM
3 ms
STARTUP, PARSING, & SHUTDOWN
Parameters
URL Parameters:
MESSAGE=logout
CGI Variables:
AUTH_GROUP=
AUTH_TYPE=
AUTH_USER=
CF_TEMPLATE_PATH=/data/webdata/docs-443/logout.cfm
CLIENT_CERT=
CLIENT_CERT_ISSUER_DN=no certificate
CLIENT_CERT_SSL_ID=
CLIENT_CERT_USER_DN=no certificate
CONTENT_LENGTH=
CONTENT_TYPE=
HTTP_ACCEPT=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
HTTP_ACCEPT_CHARSET=iso-8859-1,*,utf-8
HTTP_ACCEPT_ENCODING=gzip
HTTP_ACCEPT_LANGUAGE=en
HTTP_CONNECTION=Keep-Alive
HTTP_COOKIE=CFID=56046; CFTOKEN=68180615; EDESK_USER=lmcfrob%40lmc%2Eericsson%2Ese
HTTP_HOST=edesk.ericsson.ca
HTTP_REFERER=HTTP_USER_AGENT=Mozilla/4.7 [en]C-CCK-MCD(WinNT; U)
PATH_INFO=
PATH_TRANSLATED=/data/webdata/docs-443/logout.cfm
QUERY_STRING=message=logout
REMOTE_ADDR=192.75.88.40
REMOTE_HOST=
REMOTE_USER=
REQUEST_METHOD=GET
SCRIPT_NAME=/logout.cfm
SERVER_NAME=edesk.ericsson.ca
SERVER_PORT=443
SERVER_PROTOCOL=HTTP/1.0
SERVER_SOFTWARE=Netscape-Enterprise/3.6 SP3
 
Hi Francisr!

I checked your code... I dont really know what's the exact error but I have some concern about it...
Here a copy paste of a part of it:

<cfif IsDefined(&quot;flashinstalled&quot;) AND flashinstalled IS 2>
[tab]<cfset banner = &quot;flash&quot;>
[tab]<cfset session.showSeasonGreetingsBanner = false>
<cfelseif> <------- that tag must have a condition in it[tab]<cfset banner = &quot;christmas_banner.gif&quot;>
[tab]<cfset session.showSeasonGreetingsBanner = false>
</cfif> <------- that tag should not be there
<cfelse>
[tab]<cfset banner = &quot;top_banner.gif&quot;>
</cfif>

but this is not my major concern... you are using script that is run on the client and then use the result in CF... Your CF page will have already run when you will get those results... In the <CFIF> I pasted above the &quot;flashinstalled&quot; variable will NEVER be defined. Dont forget, CF is server side (so run first) and then the generated page run on the client side...

That's a beginning of an answer for you...
I dont really know how to detect if flash is installed but if you are inside the Ericsson intranet and that everyone is using IE it's not a problem, IE will automaticaly download the plugin and run your flash animation!

Have fun,
Chris ;-)
 
onirike is right.. CF will never see the results of the script, because the script runs on the client side, after CF ran it's code...

The error you got, though, is probably (99% sure) a typo that is causing the CF parser to not be able to process the page. I'd be willing to bet you're missing a pound sign around a variable, or are calling a background color inside a CFOUTPUT without escaping the pound sign...

I think the best way to handle this is to run your script then redirect to either the flash or non-flash cold fusion page from within the script....

Good luck..:)

DM
 
This line:
Code:
<PARAM NAME=movie VALUE=&quot;christmas_banner.swf&quot;> <PARAM NAME=loop VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src=&quot;/morceaux/christmas_banner.swf&quot; loop=false quality=high bgcolor=#FFFFFFWIDTH=434 HEIGHT=30 TYPE=&quot;application/x-shockwave-flash&quot; PLUGINSPAGE=&quot;[URL unfurl="true"]http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&quot;></EMBED>[/URL]

You may need to do a double pound ## where you declare your colors. But listen to DarkMan's idea about redirecting from within the script. May be the best way to go. Kevin
slanek@ssd.fsi.com
 
Just about every browser today will work without the pound sign before a color... You may do even better to remove them completely... Also, in that code, your #FFFFFF runs right into the WIDTH=434. You need to have a space between the parameters otherwise it'll read bgcolor=#FFFFFFWIDTH=434 as one parameter....
 
No kidding? I didn't know you could omit the pound sign in colors. I'll have to try that. Thanks. Kevin
slanek@ssd.fsi.com
 
B-) <disclaimer>Remember, I said &quot;just about every browser&quot;... I haven't tried it in all browsers, and I'm not sure how backward compatible it is, although I know it works in at least the last three or four releases of both IE and Netscape.</disclaimer>

It's definitely be worth checking out, though (especially for us CF programmers where that pound sign can cause a lot of trouble). Let me know if you see any hard documentation of this. I'm still coding the pound signs, but if I was sure it worked back to the 3.0 variety of browsers, I'd definitely quit using them...
 
Works great. Everyone on out intranet has at least IE4.5 so we're good to go. I don't see myself going back to change all the existing code, but I'll be doing my future coding without those pesky pounds. :) Kevin
slanek@ssd.fsi.com
 
I meant &quot;our intranet.&quot; Not &quot;out intranet.&quot; Kevin
slanek@ssd.fsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top