比如地址栏是这样的:http://www.aa.com/detail.aspx?code=1&start=2014-12-01&end=2014-12-23&name=abc
要获取到“?code=1&start=2014-12-01&end=2014-12-23&name=abc”,如下:
前台页面head标签内:
<script type="text/javascript"> function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } function GetUrlQueryString() { var query = '?'; var code = escape(GetQueryString("code")); if (code != null && code.toString().length > 0) { query += 'code=' + code + '&'; } var start = escape(GetQueryString("start")); if (start != null && start.toString().length > 0) { query += 'start=' + start + '&'; } var end = escape(GetQueryString("end")); if (end != null && end.toString().length > 0) { query += 'end=' + end + '&'; } var name = escape(GetQueryString("name")); if (name != null && name.toString().length > 0) { query += 'name=' + name; } return query; }
按钮:
<input type="button" value="导出" class="button1" onclick="javascript:window.open('ExportToExcel.aspx' + GetUrlQueryString());" />
时间: 2024-10-15 06:28:25