1

提前抱歉,这个网站上的很多答案都与这个查询的一部分有关,尽管我没有把这些点联系起来。任何帮助将不胜感激(很高兴购买虚拟啤酒等)

我正在寻找一个 URL,并在“&folderCTID”左侧和“RootFolder=”右侧提取部分字符串,例如:

这个: http : //mysite.com/Project1/Forms/AllItems.aspx?RootFolder=%2FProject1%2FLesson%2014&FolderCTID=0x01200075C0E8AC5A64724787732A3200049D3A&View= {440F5454-054D-4C68-A1E2-4A52E4FD8FCB}

变为: %2FProject1%2FLesson%2014

然后我希望用“/”替换“%2F”,并添加一个尾随“/presentation.swf”,留下我的文件引用- “/Project1/Lesson%2014/presentation.swf”

最后,我想在嵌入代码中使用文件引用,例如 src="/Project1/Lesson%2014/presentation.swf"

这甚至可能吗?

4

2 回答 2

0

简短的回答:是的

var url = "http://mysite.com/Project1/Forms/AllItems.aspx?RootFolder=%2FProject1%2FLesson%2014&FolderCTID=0x01200075C0E8AC5A64724787732A3200049D3A&View={440F5454-054D-4C68-A1E2-4A52E4FD8FCB}",
i = 0, len, part;

url = url.split("?").pop().split("&");
len = url.length;

for ( ; i < len; i++ ) {
    part = url[i].split("=");
    if ( part[0] === "RootFolder" ) {
        break;
    }
}

part = decodeURIComponent(part[1]);

console.log(part); // "/Project1/Lesson 14"
于 2013-04-18T08:56:51.773 回答
0

这对我有用

theURL='http://mysite.com/Project1/Forms/AllItems.aspx?RootFolder=%2FProject1%2FLesson%2014&FolderCTID=0x01200075C0E8AC5A64724787732A3200049D3A&View={440F5454-054D-4C68-A1E2-4A52E4FD8FCB}';

filePath = theURL.match(/RootFolder\=(.*?)&/)[1].replace(/%2F/g, "/")+"/presentation.swf";

alert(filePath);

我认为您甚至不需要解码 url 即可在 src 中使用它,因此您可以使用

filePath = theURL.match(/RootFolder\=(.*?)&/)[1]+"%2Fpresentation.swf";

尝试 SWFObject https://code.google.com/p/swfobject/wiki/documentation

<!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 dynamic embed - 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.embedSWF(filePath, "myContent", "300", "120", "9.0.0");
    </script>

  </head>
  <body>
    <div id="myContent">
      <p>Alternative content</p>
    </div>
  </body>
</html>

或者如果您使用的是 jQuery,您可以尝试http://jquery.lukelutman.com/plugins/flash/

$(document).ready(function(){
    $('#example').flash(
        { src: filePath,
          width: 720,
          height: 480 },
        { version: 8 }
    );
});

<div id="example">You don't have flash</div>

http://jquery.thewikies.com/swfobject/

$(document).ready(
    function() {
        $('#myFlash').flash(filePath);
    }
);

<div id="myFlash">You don't have flash</div>

我在上述示例中的正确位置包含了 filePath 变量

于 2013-04-18T09:04:50.993 回答