现在的位置: 首页 > 综合 > 正文

Js正则获取查询字符串值

2017年11月08日 ⁄ 综合 ⁄ 共 723字 ⁄ 字号 评论关闭

<script type="text/javascript">
    $(initList);

    function initList() {
        var tr = $('tr.listTrLinkNormal');
        tr.attr('onclick', '');
        tr.click(
        function () {
            var parentWindow = window.opener ? window.opener : window.dialogArguments;
            if (parentWindow) {
                var cells = $(this).find('td');
                parentWindow.SearchByMacName(cells.eq(2).text());
            }
            window.close();
        }
    );
    }

    function getParameterByName(name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
        return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }
</script>

抱歉!评论已关闭.