我有pop.jsp
两个 div 标签,当我点击时,FindByid
只能通过 id 字段显示找到,如果我点击,findByname
则该字段仅显示完美工作。但问题是,当我打开一个弹出窗口时,有时没有该字段可见或有时它可以顺利工作我不知道为什么会发生我想相应地在单击按钮时看到相应的字段
注意有时div标签的可见性仅适用于 internet explorer
其他浏览器没有div标签可见所以请解决我的问题
这是我的 index.jsp 弹出代码,我通过它弹出
<script type="text/javascript">
function windowLoadByName(windowHeight, windowWidth) {
var centerWidth = (window.screen.width - windowWidth) / 2;
var centerHeight = (window.screen.height - windowHeight) / 2;
newWindow = window.open(
'PopUp.jsp',
'mywindow',
'resizable=0,width=' + windowWidth + ',height=' + windowHeight
+ ',left=' + centerWidth + ',top=' + centerHeight,
"status=1").divHiding(1);
newWindow.focus();
}
function windowLoadById(windowHeight, windowWidth) {
var centerWidth = (window.screen.width - windowWidth) / 2;
var centerHeight = (window.screen.height - windowHeight) / 2;
newWindow = window.open(
'PopUp.jsp',
'mywindow',
'resizable=0,width=' + windowWidth + ',height=' + windowHeight
+ ',left=' + centerWidth + ',top=' + centerHeight)
.divHiding(2);
newWindow.focus();
return newWindow.name;
}
这是我的 pop.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://jakarta.apache.org/taglibs/input-1.0"
prefix="input"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
function loadByName() {
var l = document.getElementById("firstName");
var v = l.value;
window.opener.loadName(v);
window.close();
}
function loadById() {
var ids = document.getElementById("id");
var v = ids.value;
window.opener.loadId(v);
window.close();
}
function divHiding(id) {
var div1 = document.getElementById('div1');
var div2 = document.getElementById('div2');
// Check what the value of the button pressed and displays the correct div
if (id == 1)
div1.style.display = 'block';
else if (id == 2) {
div2.style.display = 'block';
}
}
</script>
</head>
<body>
<form name="employeeForm" method="get">
<div id="div1" style="display: none;">
Employee Name:
<center>
<input type="text" name="firstName" id="firstName" />
</center>
<center>
<input type="submit" name="Search" value="Search"
onclick="loadByName()" />
</center>
</div>
<div id="div2" style="display: none;">
Employee Id:
<center>
<input type="text" name="firstName" id="id" />
</center>
<center>
<input type="submit" name="Search" value="Search"
onclick="loadById()" />
</center>
</div>
</form>
</body>
</html>