• <tfoot id='2aAel'></tfoot>

    1. <legend id='2aAel'><style id='2aAel'><dir id='2aAel'><q id='2aAel'></q></dir></style></legend>

      <small id='2aAel'></small><noframes id='2aAel'>

        • <bdo id='2aAel'></bdo><ul id='2aAel'></ul>
        <i id='2aAel'><tr id='2aAel'><dt id='2aAel'><q id='2aAel'><span id='2aAel'><b id='2aAel'><form id='2aAel'><ins id='2aAel'></ins><ul id='2aAel'></ul><sub id='2aAel'></sub></form><legend id='2aAel'></legend><bdo id='2aAel'><pre id='2aAel'><center id='2aAel'></center></pre></bdo></b><th id='2aAel'></th></span></q></dt></tr></i><div id='2aAel'><tfoot id='2aAel'></tfoot><dl id='2aAel'><fieldset id='2aAel'></fieldset></dl></div>

        直接从 JavaScript 访问 GET?

        时间:2023-10-12
        <legend id='9IZGv'><style id='9IZGv'><dir id='9IZGv'><q id='9IZGv'></q></dir></style></legend>
        <i id='9IZGv'><tr id='9IZGv'><dt id='9IZGv'><q id='9IZGv'><span id='9IZGv'><b id='9IZGv'><form id='9IZGv'><ins id='9IZGv'></ins><ul id='9IZGv'></ul><sub id='9IZGv'></sub></form><legend id='9IZGv'></legend><bdo id='9IZGv'><pre id='9IZGv'><center id='9IZGv'></center></pre></bdo></b><th id='9IZGv'></th></span></q></dt></tr></i><div id='9IZGv'><tfoot id='9IZGv'></tfoot><dl id='9IZGv'><fieldset id='9IZGv'></fieldset></dl></div>

        1. <small id='9IZGv'></small><noframes id='9IZGv'>

        2. <tfoot id='9IZGv'></tfoot>
            <tbody id='9IZGv'></tbody>
              <bdo id='9IZGv'></bdo><ul id='9IZGv'></ul>

                • 本文介绍了直接从 JavaScript 访问 GET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想我可以使用 PHP 从 JavaScript 访问 $_GET 变量:

                  I suppose I could use PHP to access $_GET variables from JavaScript:

                  <script>
                  var to = $_GET['to'];
                  var from = $_GET['from'];
                  </script>
                  <script src="realScript" type="text/javascript"></script>
                  

                  但也许更简单.有没有办法直接从JS做到这一点?

                  But perhaps it's even simpler. Is there a way to do it directly from JS?

                  推荐答案

                  window.location.search
                  

                  它将包含这样的字符串:?foo=1&bar=2

                  It will contain a string like this: ?foo=1&bar=2

                  要将其转化为对象,您只需要进行一些拆分:

                  To get from that into an object, some splitting is all you need to do:

                  var parts = window.location.search.substr(1).split("&");
                  var $_GET = {};
                  for (var i = 0; i < parts.length; i++) {
                      var temp = parts[i].split("=");
                      $_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
                  }
                  
                  alert($_GET['foo']); // 1
                  alert($_GET.bar);    // 2
                  

                  这篇关于直接从 JavaScript 访问 GET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将适用于 Windows 的 PHP 5.3 扩展编译为 DLL? 下一篇:如何检查 $_GET 是否为空?

                  相关文章

                  <legend id='eBH9R'><style id='eBH9R'><dir id='eBH9R'><q id='eBH9R'></q></dir></style></legend>
                  <i id='eBH9R'><tr id='eBH9R'><dt id='eBH9R'><q id='eBH9R'><span id='eBH9R'><b id='eBH9R'><form id='eBH9R'><ins id='eBH9R'></ins><ul id='eBH9R'></ul><sub id='eBH9R'></sub></form><legend id='eBH9R'></legend><bdo id='eBH9R'><pre id='eBH9R'><center id='eBH9R'></center></pre></bdo></b><th id='eBH9R'></th></span></q></dt></tr></i><div id='eBH9R'><tfoot id='eBH9R'></tfoot><dl id='eBH9R'><fieldset id='eBH9R'></fieldset></dl></div>
                    <bdo id='eBH9R'></bdo><ul id='eBH9R'></ul>

                  <tfoot id='eBH9R'></tfoot>
                • <small id='eBH9R'></small><noframes id='eBH9R'>