【问题标题】:Find the first sub site name in current URL在当前 URL 中查找第一个子站点名称
【发布时间】:2015-02-23 16:43:48
【问题描述】:

我正在检查当前网址。如果我当前的子站点来自根站点的第一个子站点具有属性。但我想让它不区分大小写,这样无论是属性还是属性都可以正常工作。

有没有更好的方法来做到这一点这是我目前的方法..

<script type="text/javascript">
        $(document).ready(function () {
            var url = window.location.href;
            var host = window.location.host;

            if (url.indexOf('http://' + host + '/property') != -1) {
                $('.propertytitle').hide();
            }
            else if (url.indexOf('http://' + host + '/Property') != -1) {
                $('.propertytitle').hide();
            }
            else {
                $('propertytitle').show();
            }

        });
    </script>

【问题讨论】:

    标签: jquery asp.net jquery-ui sharepoint sharepoint-2013


    【解决方案1】:

    为了使其不区分大小写,您可能希望在第一步中将 url 和 host 都更改为小写。

    var url = window.location.href.toLowerCase();
    var host = window.location.host.toLowerCase();
    
    if (url.indexOf('http://' + host + '/property') != -1) {
             $('.propertytitle').hide();
    }
    else {
             $('propertytitle').show();
    }
    

    【讨论】:

      猜你喜欢
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-16
      • 2010-12-15
      • 2011-02-06
      • 1970-01-01
      • 2012-03-04
      相关资源
      最近更新 更多