Solved

Page redirect based on condition

Posted on 2008-10-20
5
465 Views
Last Modified: 2013-11-11
Hey experts,

  I have this html code (in the snippet below); upon display of the page, if the browser doesn't have a flash player plugin (or if flash isn't supported), the div with id flashcontent will display showing link to default.htm; what I want to happen is that the page gets redirected automatically to default.htm; any idea on how to do that??
P.S.: I know how to do it using META HTTP-EQUIV, but this is without a condition like the one below (i.e. to do the redirection only if flash is not supported)

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LFZ holding</title>
<script type="text/javascript" src="swfobject.js"></script>
<style type="text/css">
            /* hide from ie on mac \*/
            html {
                        height: 100%;
                        overflow: hidden;
            }
            
            #flashcontent {
            
            }
            /* end hide */
 
            body {
                        height: 100%;
                        margin: 0;
                        padding: 0;
                        background-color: #ffffff;
            }
</style>
</head>
 
<body>
<table border="0" width="100%" id="table1" height="100%" cellspacing="0" cellpadding="0">
                <tr>
                                <td>
  <div id="flashcontent"><a href="lfz%20html/default.htm">dfgdf</a></div> 
  <script type="text/javascript">
                        // <![CDATA[
                        
                        var so = new SWFObject("main.swf", "sotester", "100%", "100%", "8", "#FFFFFF");
                        so.addVariable("flashVarText", "this is passed in via FlashVars for example only");
                        so.addParam("scale", "noscale");
                        so.write("flashcontent");
                        
                        // ]]>
            </script>  
  </td>
</tr>
</table>
</body>
</html>

Open in new window

0
Comment
Question by:mte01
[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
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
patricka_0377 earned 350 total points
ID: 22756193
i think this is it roughly
if (pluginlist.indexOf("Flash")==-1) {
location.replace("pagewithnoflash.htm"); //redirect to no flash page
}

Open in new window

0
 
LVL 3

Author Comment

by:mte01
ID: 22756230
>>patricka_0377

Ok; I'll try it, and I'll inform you with the results
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 22764577
as You are using "swfobject", you can simple add following line of code to redirect if flash is not found:


   so.setAttribute('xiRedirectUrl', 'http://www.example.com/upgradefinished.html'); // must be the absolute URL to your site
   so.write("flashcontent");
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 22764583
sorry, please ignore code in previous comment, it should be as following:

so.setAttribute('redirectUrl', 'html/index.php');
so.write("flashcontent");
0
 
LVL 3

Author Comment

by:mte01
ID: 22784312
>>aneeshchopra

Your code didn't work since itdoesn't create the swfobject when there's no flash plugin in the browser

>>patricka_0377

Your code did the trick! I just had to use http://www.oreillynet.com/pub/a/javascript/2001/07/20/plugin_detection.html to assist me in the rest of the code; many thanks for your help :)
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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

729 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