js 关闭页面

  var browserName=navigator.appName;
if (browserName=="Netscape") {
     window.open('','_parent',''); window.close(); }
else if (browserName=="Microsoft Internet Explorer") {
     window.opener = "whocares"; window.close(); }

  

Js 手机验证
<script>
var mobile = "";
var code = "";
function CheckMobile() {
mobile = $.trim($("#MobileNumber").val());
if (mobile.length == ) {
alert('请输入手机号码')
return false;
} else if (!/\d{}/i.test(mobile)) {
alert('手机号码格式不正确')
return false;
}
return true;
}
function checkValidateCode() {
code = $.trim($("#CheckCode").val());
if (code.length == ) {
alert('请输入验证码')
return false;
} else if (code.length != ) {
alert('验证码位数不正确')
return false;
} else if (!/^(\d{})$/i.test(code)) {
alert('验证码格式不正确')
return false;
}
return true;
}
jQuery(function () {
$("#btnSubmit").click(function () {
if (!CheckMobile())
return false;
if (!checkValidateCode())
return false;
$.post("@Url.Action("Bind", "Home")", { "MobileNumber": mobile, "CheckCode": code }, function (data) {
if (data.Result != undefined && data.Result != null && data.Result)
window.location.replace("/home/mybaby");
else
alert(data.Message);
});
});
$("#btnSendValidate").click(function () {
var $this = $(this);
var flag = CheckMobile();
if (!flag)
return false; var timeless = ;
$this.html("已发送(" + timeless + ")");
$this.attr("disabled", "disabled")
var t = setInterval(function () {
if (timeless > ) {
timeless--;
$this.html("已发送(" + timeless + ")");
} else {
$this.html("获取验证码");
$this.removeAttr("disabled");
clearInterval(t);
}
}, );
$.ajax({
url: "@Url.Action("SendCode","Home")", type: "POST", dataType: "json", contentType: "application/json;utf-8",
data: JSON.stringify({ MobileNumber: mobile }),
success: function (data) {
if (data.Message != undefined && data.Message != null) {
alert(data.Message);
}
},
error: function (err) {
alert('绑定异常')
}
});
return false;
});
});
</script>

3. js.ajax

 $.ajax({
type: "Get",
url: "/home/DropdownClass",
dataType: "Json",
success: function (data) {
$.each(data, function (index, ele) {
content += " <li tag='" + ele.Value + "' onclick='otherclass(this)'>" + ele.Text + " 共(" + ele.Num + ")人 </li>"
});
$("#dropdwonclass").html(content);
}
});

4. js.跳转

js方式的页面跳转
.window.location.href方式
<script language="javascript" type="text/javascript">
window.location.href="target.aspx";
</script> .window.navigate方式跳转
<script language="javascript">
window.navigate("target.aspx");
</script> .window.loction.replace方式实现页面跳转,注意跟第一种方式的区别
<script language="javascript">
window.location.replace("target.aspx");
</script>
有3个jsp页面(.aspx, .aspx, .aspx),进系统默认的是1.aspx,当我进入2.aspx的时候, .aspx里面用window.location.replace("3.aspx"); 与用window.location.href ("3.aspx"); 从用户界面来看是没有什么区别的,但是当3.aspx页面有一个"返回"按钮,调用window.history.go(-); wondow.history.back();方法的时候,一点这个返回按钮就要返回2.aspx页面的话,区别就出来了,当用 window.location.replace("3.aspx");连到3.aspx页面的话,.aspx页面中的调用 window.history.go(-);wondow.history.back();方法是不好用的,会返回到1.aspx。 .self.location方式实现页面跳转,和下面的top.location有小小区别
<script language="JavaScript">
self.location='target.aspx';
</script> .top.location
<script language="javascript">
top.location='target.aspx';
</script> .不推荐这种方式跳转
<script language="javascript">
alert("返回");
window.history.back(-);
</script> meta方式实现跳转(content = 单位是秒)
<meta http-equiv=refresh content=;URL="http://www.dayanmei.com">

最新文章

  1. ProceedingJoinPoint获取当前方法
  2. git和svn
  3. Android Studio 连接真机不识别
  4. mesos INSTALL
  5. Xcode 插件失效的临时解决方案
  6. tornado框架之路二
  7. JS 函数调用
  8. Delphi- 数据加密和解密
  9. c语言:蜗牛的爬行。
  10. POJ 3468 A Simple Problem with Integers(线段树区间求和)
  11. hdu1043
  12. Java 并发 – 线程安全?
  13. JavaWeb(一)Servlet中乱码解决与转发和重定向的区别
  14. ASP.NETCore的Kestrel服务器
  15. R语言︱SNA-社会关系网络 R语言实现专题(基础篇)(一)
  16. HashSet源码分析
  17. Entity Framework Core Code First
  18. 洛谷 P1054 解题报告
  19. About the Mean Shift
  20. Intel:从屌丝逆袭成业界大佬

热门文章

  1. 【LeetCode】2、Add Two Numbers
  2. 【Linq】标准查询操作符
  3. 刽子手游戏(Hangman Judge, UVa 489)
  4. (C/C++学习)5.C++中的虚继承-虚函数-多态解析
  5. models中,对于(Small)IntegerField类型字段的choices参数在前端的展示
  6. collections、random、hashlib、configparser、logging模块
  7. Eclipse中使用struts标签时出错
  8. Girls Love 233
  9. 清北学堂模拟赛d1t5 拍照(photo)
  10. 《鸟哥的Linux私房菜-基础学习篇(第三版)》(五)