javascript 获取url参数的正则表达式(用来获取某个参数值)

所属分类: 网络编程 / 正则表达式 阅读数: 301
收藏 0 赞 0 分享
例子:
//javascript传参数(多个)
var url = "B.aspx?txtA="+document.getElementById("txtName").value;
url +="&txtB="+document.getElementById("txtAge").value;
window.open(url,'xWindow','width=640,height=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,top=250,left=430');
//B.aspx目标页取得
复制代码 代码如下:

<scirpt language='javascirpt'>
<!--
function GetStringValue()
{
String.prototype.getQueryString = function(name)//name 是URL的参数名字
{
var reg = new RegExp("(^|&|\\?)"+ name +"=([^&]*)(&|$)"), r;
if (r=this.match(reg)) return unescape(r[2]); return null;
};
//直接可以传参数名 就可以 得到参数的值
alert(window.location.href.getQueryString("txtA")+window.location.href.getQueryString("txtB"));
}
-->
</scirpt>

window.open和 window.location区别:
window.open是打开新窗口
window.location是将本页替换了,也就是定位
onclick="javascript:window.location.href='XXXX.aspx';"
JavaScript URL参数读取改进版
https://www.jb51.net/article/17116.htm
更多精彩内容其他人还在看

能说明一下GETROWS的用法吗?

能说明一下GETROWS的用法吗?
收藏 0 赞 0 分享

用正则表达式过滤html代码

用正则表达式过滤html代码
收藏 0 赞 0 分享

ubb js

ubb js
收藏 0 赞 0 分享

正则表达式在javascript中的几个实例

正则表达式在javascript中的几个实例
收藏 0 赞 0 分享

简单的Html转换UBB的程序

简单的Html转换UBB的程序
收藏 0 赞 0 分享

求个简单正则

求个简单正则
收藏 0 赞 0 分享

JScript中正则表达式用法详解

JScript中正则表达式用法详解
收藏 0 赞 0 分享

取图片路径的正则

取图片路径的正则
收藏 0 赞 0 分享

文本框输入限制 [大全]

文本框输入限制 [大全]
收藏 0 赞 0 分享

UBB代码在论坛中的应用

UBB代码在论坛中的应用
收藏 0 赞 0 分享
查看更多