Javascript查询字符串参数flashvar与swfobject

时间:2010-11-04 22:22:14

标签: javascript swfobject flashvars querystringparameter

在网页的head部分使用javascript函数,我已经能够解析查询字符串并将其作为flashvar发送到swf,构建嵌入了一个JS函数的对象,如下所示:

...

function writeFlash() {
 var width = '1024'
 var height = '500'
 var src = 'j.swf'
 var queries = 'im='+QueryString('im')+'.jpg'
 var l1 = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="'+width+'" height="'+height+'">;'
 var l2 = '<param name="movie" value="'+src+'" />;'
 var l6 = '<param name="flashvars" value="'+queries+'" />;'
 var l3 = '<param name="quality" value="high" />;'
 var l4 = '<embed src="'+src+queries+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>;'
 var l5 = '</object>'
 document.write(l1+l2+l6+l3+l4+l5)
}

...

在页面正文中,我将该函数称为打开swf,就像这样。

...

<script language="JavaScript" type="text/javascript">
<!-- 
writeFlash();
-->
</script> 

...

我想改用SWFobject(我也在其他地方使用加载JW播放器)。当我尝试将我的嵌入转换为swfobject代码时,我无法通过我尝试过的多种方式来改变flashvar,请帮忙。

1 个答案:

答案 0 :(得分:0)

但为什么在闪光灯中你可以做ExternalInterface.call("eval", "document.location.search")

也不要使用swfobject。查看静态发布,这对于新浏览器来说更清晰,更好。

以下是一个例子:

<!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 - step 3</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="swfobject.js"></script>

    <script type="text/javascript">
    swfobject.registerObject("myId", "9.0.115", "expressInstall.swf");
    </script>
  </head>
  <body>
    <div>
      <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">
        <param name="movie" value="myContent.swf" />
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="420">
        <!--<![endif]-->
          <p>Alternative content</p>
        <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
      </object>
    </div>
  </body>
</html>