按钮(button) 关闭 返回上一页 的写法

 1.JavaScript返回上一页代码区别:

  1. window.history.go(-1);  //返回上一页
  2. window.history.back();  //返回上一页
  3. 如果要强行刷新的话就是:window.history.back();location.reload();
  4. window.location.go(-1); //刷新上一页

 2.不带任何提示关闭窗口的js代码

<a href="javascript:window.opener=null;window.open('','_self');window.close();">关闭</a>

 3.自定义提示关闭

<script language="javascript">
// 这个脚本是 ie6和ie7 通用的脚本
function custom_close(){
if 
(confirm("您确定要关闭本页吗?")){
window.opener=null;
window.open('','_self');
window.close();
}
else{}
}
</script>

<input id="btnClose" type="button" value="关闭本页" onClick="custom_close()" />

猜你喜欢

转载自fengyeqing5.iteye.com/blog/2381187