ouyang789987 / swfobject

Automatically exported from code.google.com/p/swfobject
0 stars 0 forks source link

Can't use & properly within the embed SWF command #342

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi Guys,

I have the following string :

http://www.muzu.tv/player/getPlayer/a/q8MY2YPnLE/autostart=y&includeAll=n&am
p;soundoff=n&vidId=258092&playlistId=232763&videotype=hq

I am using this straight into the embed section of swfObject which works
fine in Internet Explorer but when using the code in Firefox, Opera, Safari
or Chrome, swfObject will only pick up the first variable and drop
everything after it.

If I change the string to the following:

http://www.muzu.tv/player/getPlayer/a/q8MY2YPnLE/autostart=y&includeAll=n&soundo
ff=n&vidId=258092&playlistId=232763&videotype=hq

It works in all browsers but will not pass W3C Validation which is the main
reason I use the brilliant swfObject!!  Any ideas as to why this is happening?

Thanks In Advance

What steps will reproduce the problem?
1. Insert the following code into the head of a webpage

<script language="javascript" type="text/javascript"
src="../scripts/swfobject.js"></script>
<script language="javascript" type="text/javascript">
var flashvars = false;

var params = {
  movie:
"http://www.muzu.tv/player/getPlayer/a/q8MY2YPnLE/autostart=y&amp;includeAll=n&a
mp;soundoff=n&amp;vidId=258092&amp;playlistId=232763&amp;videotype=hq",
  allowScriptAccess: "always",
  allowFullScreen: "true",
  quality: "high",
  wmode: "transparent"
};

var attributes = false;

swfobject.embedSWF("http://www.muzu.tv/player/getPlayer/a/q8MY2YPnLE/autostart=y
&amp;includeAll=n&amp;soundoff=n&amp;vidId=258092&amp;playlistId=232763&amp;vide
otype=hq",
"MuzuPlayer", "560", "330", "8.0.0", "expressInstall.swf", flashvars,
params, attributes);
</script>

2. Paste this code into the body of the webpage

<div title="" id="MuzuPlayer">
    <h1>Unable To Play Video...</h1>
    <strong>You need to upgrade your Flash Player, Enable Flash or Turn on
Javascript in order to view the content</strong><br/>
    <p><a href="http://www.adobe.com/go/getflashplayer"><img
src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt="Get Adobe Flash player" /></a></p>
</div>

3. Open in IE and everything is fine. Open in Firefox, Safari, opera or
Chrome and only the first variable is registered.  If you then change the
header code to the following:

<script language="javascript" type="text/javascript"
src="../scripts/swfobject.js"></script>
<script language="javascript" type="text/javascript">
var flashvars = false;

var params = {
  movie:
"http://www.muzu.tv/player/getPlayer/a/q8MY2YPnLE/autostart=y&amp;includeAll=n&a
mp;soundoff=n&amp;vidId=258092&amp;playlistId=232763&amp;videotype=hq",
  allowScriptAccess: "always",
  allowFullScreen: "true",
  quality: "high",
  wmode: "transparent"
};

var attributes = false;

swfobject.embedSWF("http://www.muzu.tv/player/getPlayer/a/q8MY2YPnLE/autostart=y
&includeAll=n&soundoff=n&vidId=258092&playlistId=232763&videotype=hq",
"MuzuPlayer", "560", "330", "8.0.0", "expressInstall.swf", flashvars,
params, attributes);
</script>

4.  Then open in Firefox, Safari, Opera or Chrome and all variables are
registered and script functions as it should but will not pass W3C standards.

What version of the product are you using? On what operating system?
swfObject 2.2
Windows XP

Thanks in Advance :)

Dan Perkins.

Original issue reported on code.google.com by dmcdjonl...@gmail.com on 14 Jul 2009 at 1:30

GoogleCodeExporter commented 9 years ago
Managed to get round the issue by encasing everything within the script tags in
commment tags which then validates --

<script language="javascript" type="text/javascript"
src="../scripts/swfobject.js"></script>
<script language="javascript" type="text/javascript">
var flashvars = false;
<!--
var params = {
  movie:
"http://www.muzu.tv/player/getPlayer/a/q8MY2YPnLE/autostart=y&includeAll=n&sound
off=n&vidId=258092&playlistId=232763&videotype=hq",
  allowScriptAccess: "always",
  allowFullScreen: "true",
  quality: "high",
  wmode: "transparent"
};

var attributes = false;

swfobject.embedSWF("http://www.muzu.tv/player/getPlayer/a/q8MY2YPnLE/autostart=y
&includeAll=n&soundoff=n&vidId=258092&playlistId=232763&videotype=hq",
"MuzuPlayer", "560", "330", "8.0.0", "expressInstall.swf", flashvars, params,
attributes);
//-->
</script>

I also tried adding CDATA tags at the beginning and end of the script but this 
had no
effect.

Original comment by dmcdjonl...@gmail.com on 14 Jul 2009 at 1:52

GoogleCodeExporter commented 9 years ago
This is not a SWFObject issue.

More info on JavaScript URL encoding:
- http://www.permadi.com/tutorial/urlEncoding/
- our faq Q9: http://code.google.com/p/swfobject/wiki/faq
- http://kb2.adobe.com/cps/141/tn_14143.html

And of course it doesn't make sense to use an HTML validator to validate your
JavaScript code ;-)

Original comment by bobbyvandersluis on 15 Jul 2009 at 9:49