Solved

Browser Sniffer: Flash File

Posted on 2004-04-10
9
208 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
  • 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
 

Author Comment

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

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


0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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.
#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
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 +…

706 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now