Issues with detect and redirect using SWFobject

121 views
Skip to first unread message

Nick

unread,
Mar 19, 2012, 6:33:21 PM3/19/12
to swfo...@googlegroups.com

Hi everyone,

I have recently built a non-flash version of my website that I would like to be able to implement a detect and redirect to. I have tried multiple methods after reading the SWFObject docmentation and still havent been able to get it to work.

The js file for SWFobject resides under pathway js/swfobject.js

I have tried using fo.vars redirctURL, If/else methods, etc.

I used dynamic publishing with the generator and tried to include a redirect in the alternate method to no avail.

All I need is a simple redirect. I.E. if the user has FP 6.0 or higher, they get directed to the flash site. For lower flash versions, or no flash at all they get directed to the non-flash site.

Any help would be greatly appreciated:

Here is the main chunk of code I have been working with, excluding all the other HTML stuff on the site:

<head>
<script>
if (swfobject.hasFlashPlayerVersion("7.0.0")) {
// User has flash

   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <script type="text/javascript" src="js/swfobject.js"></script>
  <script type="text/javascript">
   var flashvars = {};
   var params = {};
   params.quality = "best";
   params.bgcolor = "ebebea";
   var attributes = {};
   attributes.id = "non-flash";
   swfobject.embedSWF("flash/menu_vf8.swf", "Non-flash", "980", "190", "6.0.0", false, flashvars, params, attributes);
  </script>
       
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <script type="text/javascript" src="js/swfobject.js"></script>
  <script type="text/javascript">
   var flashvars = {};
   var params = {};
   params.quality = "best";
   params.bgcolor = "ebebea";
   var attributes = {};
   attributes.id = "non-flash 1";
   swfobject.embedSWF("flash/slideshow_vf8.swf", "Non-flash 1", "980", "486", "6.0.0", false, flashvars, params, attributes);
  </script>

} else {
// User does not have flash
window.location="non-flash/index.html";
}
</script>
 </head>
<body id="page1">
<div id="main">
<!-- header -->
<body>
<div id="Non-flash">
</div>

<div id="Non-flash 1">
</div>
</body>

Aran Rhee

unread,
Mar 20, 2012, 11:10:29 AM3/20/12
to swfo...@googlegroups.com
Here are some concepts / things you will need to put in place:

1) you need to include the swfoject.js library (once) in the head section, BEFORE you try to run any logic (if / else conditions etc)
2) meta tags don't go in your script blocks
3) DOM id's don't have spaces in them (attributes.id) (accroding to the HTML spec - "ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").")
4) You have multiple body tags and unclosed div tags in your code

So, that all being said, a working example would look like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>SWFObject 2 API swfobject.hasFlashPlayerVersion example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
if (swfobject.hasFlashPlayerVersion("7.0.0")) {
 alert("I got some Flash");
                  // call multiple embedSWF() calls here etc (you don;t need separate script blocks)
}
else {
}
</script>
</head>
<body>
</body>
</html>


Aran


--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swfobject/-/9uF-vpZEHWoJ.
To post to this group, send email to swfo...@googlegroups.com.
To unsubscribe from this group, send email to swfobject+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swfobject?hl=en.

Nick

unread,
Mar 20, 2012, 1:13:05 PM3/20/12
to swfo...@googlegroups.com
Thank you Aran,
 
I seem to have gotten the code to function properly, but now I have another question. The site loads fine on my computer using both IE and FF, both my main flash menu and the flash below it load fine. However, on other computers only the top menu loads and the second flash content does not. It loads fine in IE once I run the site in compatability mode, but why would one FC work, but the other not? 
 
Any help would be greatly appreciated! 
 
Thanks in advance,
Nick  

Aran Rhee

unread,
Mar 20, 2012, 1:25:12 PM3/20/12
to swfo...@googlegroups.com
Not really sure without being able to see the actual page. It could be many things. Can you post a link to your page?

BTW - Did you change the dom id on the 2nd div to be valid (as I pointed out in my 1st reply)


Aran

--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swfobject/-/FMLwLw08q_wJ.

Nick

unread,
Mar 20, 2012, 1:47:55 PM3/20/12
to swfo...@googlegroups.com
Aran,
 
I went back and looked at the second dom ID and sure enough it still contained a space, taking out the space in the dome ID seemed ,to do the trick with the second flash object not appearing. 
 
There seems to be a small line of of pixels underneath my flash content and after doing some research I found that the CSS Style need to be set to display:block to fix it in FF, however I cant seem to get the spacing to go away in IE8. Any advice? 
 
Once again, thank you very much for your help!

Aran Rhee

unread,
Mar 20, 2012, 1:52:43 PM3/20/12
to swfo...@googlegroups.com
CSS styles are departing from the scope of this list. You would be better served asking elsewhere on that one. I am glad the rest of the issues are sorted now though.


Cheers,
Aran

--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swfobject/-/uMvIn-JmmRwJ.
Reply all
Reply to author
Forward
0 new messages