Solved

Browser Sniffer: Flash File

Posted on 2004-04-10
9
209 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Internet is a big network which is formed by connecting multiple small networks.It is a platform for all the users which are connected to it.Internet act as platform in different fields. Such as: Internet  as a collaboration platform. Internet  as…
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 to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
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.

863 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

26 Experts available now in Live!

Get 1:1 Help Now