Getting the url parameters inside the html page

后端 未结 4 960
旧时难觅i
旧时难觅i 2020-12-30 07:16

I have a html page which is loaded using a url that looks a little like this:

http://localhost:8080/GisProject/MainService?s=C&o=1

I wo

4条回答
  •  萌比男神i
    2020-12-30 07:35

    Let's get a non-encoded URL for example:

    https://stackoverflow.com/users/3233722/pyk?myfirstname=sergio&mylastname=pyk

    Packing the job in a single JS line...

    urlp=[];s=location.toString().split('?');s=s[1].split('&');for(i=0;i

    And just use it anywhere in your page :-)

    alert(urlp['mylastname']) //pyk
    
    • Even works on old browsers like ie6

提交回复
热议问题