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";
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";
本文提供了几个常用的JavaScript代码示例,包括使用confirm对话框确认用户退出、弹出消息并跳转到其他页面、返回上一页的功能实现、用button触发页面跳转以及如何控制div元素的显示与隐藏。
1575

被折叠的 条评论
为什么被折叠?



