`

javascript常用代码

阅读更多
javascript常用代码

1.用户退出系统的confim框
<input type="button" onClick="if(confirm('你确认退出吗?')) window.close();" value="退出系统">

2.弹出一个对话框后跳转到其他页面
<script>
alert("hello jsp");
location.href="http://www.baidu.com";
</script>


3.返回上一页
<a href="javascript:history.back(-1)">返回上一页</a>

<input type="button" class="button" value="返回"
onClick="javascript:history.back(-1)"/>

4.button实现超链接
<input type="button" onclick="location.href='login.jsp'" value="登录">

5.让div块隐藏
document.getElementById("divname").style.display = "none";

如果希望恢复的话则写成:
document.getElementById("divname").style.display = "inline";
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics