从Sharepoint Online中快速启动打开新窗口

时间:2014-03-05 23:49:20

标签: sharepoint sharepoint-online

<script type="text/javascript">

  //add an entry to the _spBodyOnLoadFunctionNames array
  //so that our function will run on the pageLoad event
  _spBodyOnLoadFunctionNames.push("rewriteLinks");

  function rewriteLinks() {
    //create an array to store all the anchor elements in the page
    var anchors = document.getElementsByTagName("a");

    //loop through the array
    for (var x=0; x<anchors.length; x++) {
      //does this anchor element contain #openinnewwindow?
      if (anchors[x].outerHTML.indexOf('#openinnewwindow')>0) {
        //store the HTML for this anchor element
        oldText = anchors[x].outerHTML;

        //rewrite the URL to remove our test text and add a target instead
        newText = oldText.replace(/#openinnewwindow/,'" target="_blank');

        //write the HTML back to the browser
        anchors[x].outerHTML = newText;
      }
    }
  }

</script>

我有这个代码我放在seattle.master文件之前然后在快速启动时我编辑链接我把#openinnewwindow放在网站地址之后。在“尝试链接”上,这将打开网站。我的问题是当我保存它。然后单击它未在新窗口中打开的链接。任何想法为什么会这样?

1 个答案:

答案 0 :(得分:0)

我意识到这个代码可以工作,我需要启用发布。