【问题标题】:Sharepoint links - how to open in new tab/WindowSharepoint 链接 - 如何在新选项卡/窗口中打开
【发布时间】:2022-05-13 23:32:28
【问题描述】:

我注意到在 Sharepoint 2010 中,许多链接不支持在新选项卡/窗口中打开功能。例如,快捷菜单上的项目没有。可以开启吗?

【问题讨论】:

    标签: sharepoint


    【解决方案1】:

    使用 JavaScript 函数在 SharePoint 2010 中打开一个新窗口。

    创建函数以打开您的目标窗口,如下面提供的示例。

    function load_url(externallink)
    {
        window.open(externallink,target='_blank')
    }
    

    将函数 load_url 放在 JavaScript 文件中

    单击站点操作,选择管理内容和结构。 假设您要更改页面中的链接 http://someserver/sites/Dev/Help/HelpLinks/AllItems.aspx

    然后在子站点帮助中选择名为HelpLinks 的列表。 Dev 将是最顶层的节点(站点)。 Help 将是一个子站点,在 Help 中您可以找到 List by name HelpLinks

    1. 将显示页面中的所有链接及其标题

    2. 选择要在新标签页中打开的链接标题并右键单击。

    3. 选择编辑属性。然后在 URL 字段中调用函数为javascript:load_url('http://www.google.co.in'); 而不是http:// www.google.co.in

    否则 假设您要更改以下 URL 中的链接。 URL: http:// someserver/sites/Dev/Help/HelpLinks/AllItems.aspx

    转到

    1. 打开链接http:// someserver/sites/Dev/Help/HelpLinks/AllItems.aspx

    2. 您将找到列表的列(标题列、URL 列、摘要等)。

    3. 选择标题并单击要编辑的编辑属性

    4. 然后在 URL 字段中调用函数为 javascript:load_url('http://www.google.co.in'); 而不是 http:// www.google.co.in

    【讨论】:

      【解决方案2】:

      这个答案是这篇文章的回顾,不是我想出的答案:http://sharepointsolutions.blogspot.com/2007/09/make-selected-links-in-links-list-open.html

      第 1 步:将#openinnewwindow 添加到您要在新窗口中打开的所有超链接的末尾。

      第 2 步:然后您需要将以下脚本添加到您的 SharePoint 页面。

      [script language = "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]

      【讨论】:

      • 太棒了(并且大大提高了!) - 非常适合我们:感谢添加细节
      【解决方案3】:

      什么是“快捷菜单”?是指列表项上下文菜单还是其他?可以发个截图吗?

      • 使用了两种类型的链接。

      • 普通 HTML 锚点 - 单击时可以按住 CTRL 键。

      JavaScript 链接(菜单等)CTRL 键不起作用。如果您正在使用编辑/查看表单,那么这可能会引起您的兴趣

      特别是在第二部分中,它讨论了在列表设置 > 高级设置 > 对话框中更改此行为

      【讨论】:

        【解决方案4】:

        这实际上是 Internet Explorer 特定的错误。 SharePoint 2010 中的导航链接是常规链接,但在链接文本周围有两个嵌套的 span 标记。这让 IE 感到困惑,它没有意识到您右键单击的文本是一个链接,因此没有提供正确的上下文菜单。如果您右键单击链接文本的左侧(光标仍应显示为“手”),上下文菜单将按预期显示。

        【讨论】:

          【解决方案5】:

          对于 Sharepoint 2013,我使用了 Keith 的代码和延迟调用。

          <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() {
                  $('a').attr("target","_blank");
              }
          
          </script>
          

          【讨论】:

            【解决方案6】:

            在 SharePoint Wiki 编辑器中,您可以单击您添加的“发件人地址”链接,一个链接菜单将出现在功能区栏中。在里面,你可以点击“在新选项卡中打开”。它不完全是新窗口,但它很接近而且很容易。

            【讨论】:

              【解决方案7】:

              将此添加到链接的末尾。

              #openinnewwindow

              示例:http://www.bing.com**#openinnewwindow

              【讨论】:

                猜你喜欢
                • 2013-03-22
                • 2012-01-22
                • 2011-02-18
                • 2013-11-11
                • 2013-03-11
                • 2010-09-12
                • 2017-07-27
                相关资源
                最近更新 更多