当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 起点页面传值js,有空研究学习下

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 起点页面传值js,有空研究学习下


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-02-27   浏览: 304 ::
收藏到网摘: n/a

起点上的页面传值js,有空研究下
复制代码 代码如下:

<script>
function ChangeParam(name, value) {
var url = window.location.href;
var newUrl = "";
var reg = new RegExp("(^|)" + name + "=([^&]*)(|$)");
var tmp = name + "=" + value;
if (url.match(reg) != null) {
newUrl = url.replace(eval(reg), tmp);
}
else {
if (url.match("[\?]")) {
newUrl = url + "&" + tmp;
}
else {
newUrl = url + "?" + tmp;
}
}
//如果更换了类别,则从第1页开始
if (name != "PageIndex") {
reg = new RegExp("(^|)PageIndex=([^&]*)(|$)");
tmp = "PageIndex=1";
if (newUrl.match(reg) != null) {
newUrl = newUrl.replace(eval(reg), tmp);
}
}
location.href = newUrl;
}
function QueryMonthTicket()
{
if($("selectM")!=null && $("selectY")!=null)
{
var month=$("selectY").value+$("selectM").value;
ChangeParam("Month",month);
}
}
function GoPage()
{
var page=$("txtPage").value.trim();
if(page.length===0){
alert("请您输入页码");
return false;
};
var strNum = '1234567890';
var isNum = true;
for(var i=0;i<page.length;i+=1){
var c = page.charAt(i);
if(strNum.indexOf(c) < 0){
isNum = false;
break;
};
};
if(isNum){
if(parseInt(page)>parseInt(initTotalPage)){
alert("您输入的页数超过总页数,请重新输入!");
return false;
};
ChangeParam("PageIndex",page);
}else alert('您输入的信息有误,请重新输入!');
}
function GoEnter(evt){
evt=evt||window.event;
if(evt && evt.keyCode == 13) return GoPage();
};
</script>