如何通过查询字符串参数进行数据检索?

更新于
2026-09-30 19:17:17
1阅读来源:SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计145个文字,预计阅读时间需要1分钟。

如何通过查询字符串参数进行数据检索?

javascript查询字符串参数函数function getQueryStringArgs() { var qs=(location.search.length > 0) ? location.search.substring(1) : , args={}, items=qs.length ? qs.split(&) : [], item, name, value, i=0, len=items.length; for (; i 查询字符串参数

function getQueryStringArgs(){ var qs = (location.search.length > 0 ? location.search.substring(1) : "" ), args = {}, items = qs.length ? qs.split("&") : [], item = null, name = null, value = null, i = 0, len = items.length; for( i=0; i < len; i++){ item = items[i].split("="); name = decodeURIComponent(item[0]); value = decodeURIComponent(item[1]); if(name.length > 1){ args[name] = value; } } return args; } // 调用,假设查询字符串是 ?q=javascript&num=10 var args = getQueryStringArgs(); alert(args["q"]); //"javascript" alert(args["num"]); //"10"

如何通过查询字符串参数进行数据检索?

本文共计145个文字,预计阅读时间需要1分钟。

如何通过查询字符串参数进行数据检索?

javascript查询字符串参数函数function getQueryStringArgs() { var qs=(location.search.length > 0) ? location.search.substring(1) : , args={}, items=qs.length ? qs.split(&) : [], item, name, value, i=0, len=items.length; for (; i 查询字符串参数

function getQueryStringArgs(){ var qs = (location.search.length > 0 ? location.search.substring(1) : "" ), args = {}, items = qs.length ? qs.split("&") : [], item = null, name = null, value = null, i = 0, len = items.length; for( i=0; i < len; i++){ item = items[i].split("="); name = decodeURIComponent(item[0]); value = decodeURIComponent(item[1]); if(name.length > 1){ args[name] = value; } } return args; } // 调用,假设查询字符串是 ?q=javascript&num=10 var args = getQueryStringArgs(); alert(args["q"]); //"javascript" alert(args["num"]); //"10"

如何通过查询字符串参数进行数据检索?