Solved

Browser Sniffer: Flash File

Posted on 2004-04-10
9
212 Views
Last Modified: 2006-11-17
I have a page where I have a flash piece loaded into the page, if someone who is on a linux bos that doesn't support flash i would like to replace that "X" out flash object with an image.. Does anyone have any code to do so?

Thanks,
Natacha
0
Comment
Question by:ngjones
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10798339
At the place in the page where the flash or image goes use a scriptlike this to dynamically write the page:

<script type="text/javascript">
<!--
    nav=navigator.userAgent.toLowerCase();
    if (nav.indexOf("inux")!=-1)
         document.write('<img src="yourimage.gif">');
   else
         document.write('<object etc... all you flash code>'):
 //-->
</script>
0
 

Author Comment

by:ngjones
ID: 10798439
That doesn't seem to work if I follow what you said to do:

<script type="text/javascript">
<!--
    nav=navigator.userAgent.toLowerCase();
    if (nav.indexOf("inux")!=-1)
         document.write('<img src="http://www.verari.com/images/welcome2.jpg">');
   else
         document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="362" height="175" id="intro" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="intro.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<embed src="intro.swf" quality="high" bgcolor="#000000" width="362" height="175" name="intro" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>
'):
 //-->
</script>

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10798493
Yeah I can see two things.  My original had a typo.  I put : at the end of the write insted of ; and it looks like you have linefeeds in the string, Javascript treats end of line as end of command, so the code was invalid.  Let's try it this way:

<script type="text/javascript">
<!--
    nav=navigator.userAgent.toLowerCase();
    if (nav.indexOf("inux")!=-1)
    {
         document.write('<img src="http://www.verari.com/images/welcome2.jpg">');
    }
   else
   {
         str='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
         str+='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/';
         str+='swflash.cab#version=6,0,0,0"'; width="362" height="175" id="intro" ';
         str+='align="middle">';
         str+='<param name="allowScriptAccess" value="sameDomain" />';
         str+='<param name="movie" value="intro.swf" />';
         str+='<param name="quality" value="high" />';
         str+='<param name="bgcolor" value="#000000" />';
         str+='<embed src="intro.swf" quality="high" bgcolor="#000000" ';
         str+='width="362" height="175" name="intro" align="middle"';
         str+=' allowScriptAccess="sameDomain" type="application/x-shockwave-flash"';
         str+=' pluginspage="http://www.macromedia.com/go/getflashplayer" />';
         str+='</object>';
         document.write(str);
    }
//-->
</script>
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:ngjones
ID: 10807951
It still doesn't work..

http://www.verari.com/test1.asp


0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 250 total points
ID: 10808074
I don't have a Linux setup to try it with, and it does not seem to give any errors; so the scripting seems okay.

maybe the userAgent is wrong.

right after this line:
 nav=navigator.userAgent.toLowerCase();
add:
alert(nav);

That should display the string it is using.

Cd&
0
 

Author Comment

by:ngjones
ID: 10808162
The flash file isn't showing up.. I added that extra statement...

http://www.verari.com/test1.asp 

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10808325
Okay what string does the alert display when you run with linux?

Cd&

0
 

Author Comment

by:ngjones
ID: 10808350
It doesn't show up anything on either linux or windows.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10808674
Let's clean that up a little:

<table border="0" cellspacing="0" width="355" cellpadding="5" height="184">
    <tr>
   
      <td valign="top" height="174"><font class="text">
      <p align="left"><script type="text/javascript">
    nav=navigator.userAgent.toLowerCase();
    alert(nav);
    if (nav.indexOf("inux")!=-1)
    {
         document.write('<img src="http://www.verari.com/images/welcome2.jpg">');
    }
   else
   {
         str='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
         str+='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/';
         str+='swflash.cab#version=6,0,0,0"'; width="362" height="175" id="intro" ';
         str+='align="middle">';
         
         str+='<param name="allowScriptAccess" value="sameDomain" />';
         str+='<param name="movie" value="intro.swf" />';
         str+='<param name="quality" value="high" />';
         str+='<param name="bgcolor" value="#000000" />';
         str+='<embed src="intro.swf" quality="high" bgcolor="#000000" ';
         str+='width="362" height="175" name="intro" align="middle"';
         str+=' allowScriptAccess="sameDomain" type="application/x-shockwave-flash"';
         str+=' pluginspage="http://www.macromedia.com/go/getflashplayer" />';
         str+='</object>';
         document.write(str);
    }
      </script></p></td>
    </tr>
  </table>

That looks a little better.

Cd&
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I had to do a bit of research to find the answer to this question so I thought I'd share my results.  Due to our outdated mainframe systems, we need to downgrade IE9 to IE8 in order to stay compatible.  We also needed to downgrade Java.  In order to…
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question