Page 1 of 1

get query string ด้วย javascript

Posted: 19/05/2016 5:40 pm
by jataz2

Code: Select all

<script type="text/javascript">
        $(document).ready(function () {
                 if (getQueryStringParameterByName("flgEdit") == 'Y')
                 {
                          alert("มี query string ชื่อ flgEdit ส่งมาใน URL")
                 }
        });

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