<small id='NMMVt'></small><noframes id='NMMVt'>

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

        • <bdo id='NMMVt'></bdo><ul id='NMMVt'></ul>

      1. <legend id='NMMVt'><style id='NMMVt'><dir id='NMMVt'><q id='NMMVt'></q></dir></style></legend>
      2. <tfoot id='NMMVt'></tfoot>
      3. 查明 JS-ASP 中是否存在 URL 参数

        时间:2023-10-13
          <tbody id='UJqP7'></tbody>

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

            <small id='UJqP7'></small><noframes id='UJqP7'>

            <legend id='UJqP7'><style id='UJqP7'><dir id='UJqP7'><q id='UJqP7'></q></dir></style></legend>

                <tfoot id='UJqP7'></tfoot>
                • <bdo id='UJqP7'></bdo><ul id='UJqP7'></ul>
                  本文介绍了查明 JS-ASP 中是否存在 URL 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在编辑其他人的代码,用 ASP 的服务器端 JS 编写,遇到了一个问题,可能有一个非常简单的解决方案.

                  I am editing other people's code, written in server-side JS for ASP, and have run into a problem that probably has a very simple solution.

                  我正在从这样的 URL 参数中输出一些代码:

                  I'm outputting some code from a URL param like this:

                  <%=Request.QueryString("param")%>
                  

                  问题是如果参数不存在,我需要做其他事情.所以我尝试了:

                  The problem is that if the param doesn't exist, I need to do something else. So I tried:

                  <% 
                    var param = Request.QueryString("param");
                    if (!param) { param = "Some Default Value"; }
                  %>
                  <%=param%>
                  

                  问题是 if 似乎永远不会评估为 true,即使 URL 参数丢失也是如此.我猜 !image 条件在这里不起作用.我的测试条件应该是什么?

                  The problem is that the if never seems to evaluate to true, even when the URL param is missing. I'm guessing that the !image condition doesn't work here. What should my test condition be?

                  (请放弃关于转义 URL 参数以防止 XSS 的严厉警告.)

                  (Please forgo stern warnings about doing escaping of URL params to prevent XSS.)

                  推荐答案

                  检查查询字符串参数是否存在的正确方法是使用 Count 属性:

                  The correct way to check whether a query string parameter exists is with the Count property:

                  <% 
                    var param = Request.QueryString("param");
                    if (param.Count === 0) { param = "Some Default Value"; }
                  %>
                  <%=param%>
                  

                  根据 的文档Request.QueryString,

                  Request.QueryString(parameter) 的值是一个包含所有QUERY_STRING 中出现的参数值.

                  The value of Request.QueryString(parameter) is an array of all of the values of parameter that occur in QUERY_STRING.

                  这可能是简单的 if (!param) 检查不起作用的原因.

                  That's probably why the simple if (!param) check doesn't work.

                  这篇关于查明 JS-ASP 中是否存在 URL 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何以更好的方式从 ASP 编辑 html? 下一篇:更改文件扩展名会影响 SE 排名吗?

                  相关文章

                  最新文章

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

                    • <bdo id='3rOhn'></bdo><ul id='3rOhn'></ul>
                    <tfoot id='3rOhn'></tfoot>

                    1. <small id='3rOhn'></small><noframes id='3rOhn'>

                      <legend id='3rOhn'><style id='3rOhn'><dir id='3rOhn'><q id='3rOhn'></q></dir></style></legend>