[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Browser Sniffer: Flash File

Posted on 2004-04-10
9
Medium Priority
?
221 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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 1000 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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Now-a-days, indirectly, postal services have been replaced by email services. Yes, whenever we hear the word "email" a lot of people only think of gmail. Some people still think that email and gmail are one and the same thing :-). Let's see some …
Following on from our article on "The Murky World of Consent and opt in", we thought we would issue some helpful guidance, not only on consent itself but knowing what information you are capturing, what you are doing with this data and how you can p…
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.
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 +…
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 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