Javascript 查询字符串参数 flashvar 和 swfobject

发布于 2024-09-30 21:08:43 字数 1240 浏览 1 评论 0原文

通过网页头部的 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 进行洗牌,请帮助。

With javascript functions in the head section of a webpage, I've been able to parse the querystring and send that as a flashvar to an swf, constructing the object embed with one of the JS functions like so:

...

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)
}

....

In the body of the page, I call that function to open the swf like this.

...

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

...

I'm tring to use SWFobject instead (which I am also using somewhere else to load JW player). When I try to translate my embed to swfobject code I don't manage to shuffle the flashvar through in multiple ways I've tried, please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

这样的小城市 2024-10-07 21:08:43

但是为什么在 Flash 中你可以这样做 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>

But why do that when in flash you can just do ExternalInterface.call("eval", "document.location.search")

Also don't do with swfobject. Look static publishing which is much cleaner and better for new browsers.

Here is an example of that:

<!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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文