通过javascript库JQuery实现页面跳转功能代码
通过javascript库JQuery实现页面跳转功能代码的四段代码实例如下。
实例1:
|
1
2
3
4
|
$(function(){var pn = $("#gotopagenum").val();//#gotopagenum是文本框的id属性location.href = "NewList.aspx?pagenum="+pn;//location.href实现客户端页面的跳转}); |
实例2:
实现跳转:window.location = 'user!add.action?id=1';
如果需要ajax无刷新的异步请求:
|
1
2
3
4
5
6
7
8
9
10
11
|
$.ajax({ url:'user!add.action?id=1', type:"POST", cache : false, dataType : "json", data : {activityId:activityId.val()}, success:function(data) { alert("请求成功"); }); } }); |
实例3:
button按钮在单击时激发jquery代码(里面有条件判断如果成功就让跳转页面,如果条件不满足就不让他跳转)
|
1
2
3
4
5
|
if(条件 == true){ document.location.href=目标url}else{ alert("条件为满足");} |
实例4:
通过ajax实现跳转:
|
1
2
3
4
5
6
7
|
$.ajax(function(){type:"POST",dataType:"json",url:"index.php",//请求页面data:"{id=1}",complete:function(){location.href ="http://www.169it.com"}//跳转页面}) |
浙公网安备 33010602011771号