Открыть новое окно из быстрого запуска в 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 после адреса веб-сайта. При «пробной ссылке» открывается правильный веб-сайт. Моя проблема, когда я сохраняю его. И нажмите на ссылку, она не открывается в новом окне. Любые идеи, почему это может происходить?


person Michael Downey    schedule 05.03.2014    source источник
comment
+1 за комментарии в коде. Вы проверили полученный HTML? Скрипт запускается и работает правильно?   -  person Ondrej Tucny    schedule 06.03.2014


Ответы (1)


Я понял, что для работы этого кода мне нужна включенная публикация.

person Michael Downey    schedule 28.04.2014