HTML将参数从url传递到Embed flash对象

时间:2012-10-07 17:11:12

标签: html flash url parameters

我想从url示例中获取FilePath参数: http://www.example.com/index.html?FilePath=LetsGo

浏览此文件会将其传递给html flash player脚本(“LetsGo”将播放而不是“autoload”):

<html>
<body><.......
<object classid="123456...." codebase="http://123457" id="test" height="300" align="middle" width="300">
    <param name="allowFullScreen" value="true">
    <param name="movie" value="123.swf">
    <param name="FlashVars" value="MP3=autoload.mp3&amp;JPG=autoload.jpg&amp;repeats=200">
    <embed src="123.swf" allowfullscreen="true" name="MP3JPG" flashvars="MP3=autoload.mp3&amp;JPG=autoload.jpg&amp;repeats=200" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="300" align="middle" width="300">
</object><......
</html>

我现在该怎么做?

非常感谢,

Bentzy。

1 个答案:

答案 0 :(得分:0)

获取URL参数的一种优雅方法是使用jQuery URL Parser,在这里您可以获得此实用程序。

<html>
  <head>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://raw.github.com/allmarkedup/jQuery-URL-Parser/master/purl.js"></script>

    <script>
      $(document).ready(function(){
        var filePath = $.url().param('FilePath');    

        //cool!
        alert(filePath);

        var flashObjectHtml = "<object classid='clsid:d27...' codebase='http://...' id='test' height='300' align='middle' width='300'> \
          <param name='allowFullScreen' value='true'> \
          <param name='movie' value='123.swf'> \
          <param name='FlashVars' value='MP3=" + filePath + "&amp;JPG=autoload.jpg&amp;repeats=200'> \
          <embed src='123.swf' allowfullscreen='true' name='MP3JPG' flashvars='MP3=" + filePath + "&amp;JPG=autoload.jpg&amp;repeats=200' \
          type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' height='300' \
          align='middle' width='300'> \
        </object>";

        $('#flash_wrapper').html(flashObjectHtml);

      });
    </script>
  </head>
  <body>
    <div id="flash_wrapper"></div>
  </body>
 </html>  

修改

复制上述脚本,在浏览器中保存并以这种方式调用:

[the_path_where_you_saved_this_file]/some_name.htm?FilePath=some_path

重点:这些网址参数区分大小写,因此FilePath!= filepath!= filePath