• <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?

        Access GET directly from JavaScript?(直接从 JavaScript 访问 GET?)
        <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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)

                    <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>
                        <tbody id='eBH9R'></tbody>

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