日期:2014-05-17 浏览次数:20816 次
/*
* temp.jsp
*/
<li><a href="index.jsp">div2</a></li>
/*
* index.jsp
* 页面功能:div隐藏+显示
*/
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'temp.jsp' starting page</title>
<style type="text/css">
.divHidden{ display:none;}
.divNormal{ position:absolute; width:200px;height:200px; border:solid 1px black;}
</style>
<script type="text/javascript">
function controlInCenter(con) {
if (con) {
con.style.left = (document.documentElement.clientWidth - con.clientWidth) / 2 + "px";
con.style.top = (document.documentElement.clientHeight - con.clientHeight) / 2 + "px";
}
}
function bindButtonToDiv(buttonId, divId) {
var btn = document.getElementById(buttonId);
var div = document.getElementById(divId);
if (btn && div) {
btn.onclick = function() {
var divs = document.getElementsByTagName("div");