Solved

Browser Sniffer: Flash File

Posted on 2004-04-10
9
214 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
Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

 

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

I recently found myself in a Corporate Situation where the client had requested blocking access to any and all websites except his own Domain? Easy? I am sure this would be your answer but their requirement was, this has to be done without using…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
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.

631 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