0

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

浏览它会将它传递给 html flash 播放器脚本(“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>

我怎样才能正确地做到这一点?

非常感谢,

本茨。

4

1 回答 1

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

重要的一点:这些 URL 参数区分大小写,所以 FilePath != filepath != filePath

于 2012-10-07T17:45:10.490 回答