get query string ด้วย javascript

Post a reply

Smilies
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: get query string ด้วย javascript

get query string ด้วย javascript

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

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>

Top