Javascript 为什么这个查询字符串参数在移动设备上不起作用?

Javascript 为什么这个查询字符串参数在移动设备上不起作用?,javascript,jquery,function,query-parameters,Javascript,Jquery,Function,Query Parameters,这在桌面上运行得很好。 如果url是, 然后弹出窗口显示,否则将隐藏 但它总是显示在手机上-有什么想法为什么 <!DOCTYPE html> <html> <head> <script type="text/javascript"> $(document).ready(function () { //lots of functions...

这在桌面上运行得很好。 如果url是, 然后弹出窗口显示,否则将隐藏

但它总是显示在手机上-有什么想法为什么

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript">
            $(document).ready(function () {
                //lots of functions...
                function get4(name) {
                    if (name = (new RegExp('[?&amp;]' + encodeURIComponent(name) + '([^&amp;]*)')).exec(location.search))
                    {
                        return decodeURIComponent(name[1]);
                    }
                }
                var popup = get4('popup');
                if (popup == "true")
                {
                    $('.pop_up').show();
                }
                else
                {
                    $('.pop_up').hide();
                }
            });
        </script>
    </head>
    <body>
        <!--html for popup-->
        <div class="pop_up" style="display:none;">
            ...
        </div>
    </body>
</html>

$(文档).ready(函数(){
//很多功能。。。
函数get4(名称){
if(name=(新的RegExp('[?&;]'+encodeURIComponent(name)+'([^&;]*)).exec(location.search))
{
返回组件(名称[1]);
}
}
var popup=get4('popup');
如果(弹出窗口==“真”)
{
$('.pop_up').show();
}
其他的
{
$('.pop_up').hide();
}
});
...

请尝试下面的JavaScript代码

  $(document).ready(function () {
        var arrQueryStringParams = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        if (arrQueryStringParams.indexOf("popup=true") > -1)
        {
            $('.pop_up').show();
        }
        else
        {
            $('.pop_up').hide();
        }
    });

请尝试下面的JavaScript代码

  $(document).ready(function () {
        var arrQueryStringParams = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        if (arrQueryStringParams.indexOf("popup=true") > -1)
        {
            $('.pop_up').show();
        }
        else
        {
            $('.pop_up').hide();
        }
    });

([^&;]*)).exec(location.search))起始的倒逗号在哪里?哦,对不起,我把它编辑得有点太难了。倒逗号实际上存在于我的代码中:if(name=(new RegExp('[?&;]'+encodeURIComponent(name)+'=([^&;]*)).exec(location.search))将其添加到代码中([^&;]*)).exec(location.search))起始倒逗号在哪里?哦,对不起,我把它编辑得有点难。我的代码中实际上有一个倒逗号:if(name=(newregexp('[?&;]'+encodeURIComponent(name)+'=([^&;]*)).exec(location.search))将其添加到代码中