Javascript 在Internet Explorer中第二次加载时,不加载jsp脚本
我创建了一个web页面,它由父和子格式的jsp页面组成。我使用javascript的ShowmodalDialog函数单击以弹出方式加载子jsp页面。每当弹出页面在除IE之外的所有浏览器中调用时,它都会在客户端页面中运行JSP脚本。在IE中,JSP脚本只在第一次运行,在下一次不会运行JSP脚本。提前谢谢。请做必要的事。对不起,我的英语不好Javascript 在Internet Explorer中第二次加载时,不加载jsp脚本,javascript,internet-explorer,jsp,Javascript,Internet Explorer,Jsp,我创建了一个web页面,它由父和子格式的jsp页面组成。我使用javascript的ShowmodalDialog函数单击以弹出方式加载子jsp页面。每当弹出页面在除IE之外的所有浏览器中调用时,它都会在客户端页面中运行JSP脚本。在IE中,JSP脚本只在第一次运行,在下一次不会运行JSP脚本。提前谢谢。请做必要的事。对不起,我的英语不好 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pag
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%@ page import="javax.servlet.*" %>
<%@ page import = "Precision.Biometric.PB400.App_Code.*"%>
<%@ page import = "Precision.Biometric.PB400.Presenter.*"%>
<%@ page import = "Precision.Biometric.PB400.View.*"%>
<%@ page import = "org.joda.time.format.*" %>
<%@ page import = "org.joda.time.*" %>
<%@ page import = "java.text.*" %>
<%@ page import = "java.util.*" %>
<html>
<base target="_self" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="JQuery/JQuery.js"></script>
<link type="text/css" rel="stylesheet" href="Jquery/jquery-ui-1.10.3/themes/base/jquery-ui.css" media="screen" />
<script type="text/javascript" src="JQuery/jquery-ui-1.10.3/jquery-1.9.1.js"></script>
<script type="text/javascript" language="javascript">
if (screen.width == 1024)
{
document.write('<link href="CSS/design1024.css" rel="stylesheet" type="text/css" />');
}
else
{
document.write('<link href="CSS/design.css" rel="stylesheet" type="text/css" />');
}
</script>
<script type="text/javascript" src="JQuery/jquery-ui-1.10.3/ui/jquery-ui.js">
</script>
<script type="text/javascript" src="JS/HolidayDetails/HolidayDetails.js"></script>
<title>Precision Attendance</title>
</head>
<body onload="onload()">
<%!
int admin = 1;
%>
<%
try
{
HttpSession sess = request.getSession(true);
if(sess.getAttribute("UserID")!=null)
{
admin = Integer.parseInt(sess.getAttribute("UserID").toString());
}
else
{
/*RequestDispatcher rd = request.getRequestDispatcher("Login.jsp");
if(rd != null)
rd.forward(request, response);*/
}
}
catch(Exception e)
{
}
%>
<%
HttpSession sess1 = request.getSession(true);
String Error ="";
if(sess1.getAttribute("Error")!=null)
{
Error =sess1.getAttribute("Error").toString();
}
%>
<%!
boolean restrictedGroup = false;
boolean Group1 = false;
boolean Group2 = false;
boolean Group3 = false;
boolean Group4 = false;
boolean Group5 = false;
boolean Group6 = false;
%>
<%
try
{
HttpSession sess = request.getSession(true);
HolidayDetailsPresenter hdPresenter = new HolidayDetailsPresenter();
PredefieneddataCollectionList pdfList = new PredefieneddataCollectionList();
pdfList = hdPresenter.GetPredefinedDetails(admin);
if(pdfList.size()>0)
{
if(pdfList.get(0).CompanyName.size()>0)
{
pageContext.setAttribute("companyList", pdfList.get(0).CompanyName);
}
}
if(sess.getAttribute("CompanyID") != null)
{
System.out.println("comapnid"+sess.getAttribute("CompanyID").toString());
if(pdfList.size()>0)
{
if(pdfList.get(0).CompID.size()>0)
{
int index = pdfList.get(0).CompID.indexOf(Integer.parseInt(sess.getAttribute("CompanyID").toString()));
pageContext.setAttribute("selcmbCompany", pdfList.get(0).CompanyName.get(index));
}
}
}
if(sess.getAttribute("HolidayGroup") != null)
{
String[] grp = sess.getAttribute("HolidayGroup").toString().split(":");
if(grp.length>0)
{
restrictedGroup = true;
}
for(int i=0; i<grp.length; i++)
{
if(grp[i].equals("1"))
{
Group1 = true;
}
else if(grp[i].equals("2"))
{
Group2 = true;
}
else if(grp[i].equals("3"))
{
Group3 = true;
}
else if(grp[i].equals("4"))
{
Group4 = true;
}
else if(grp[i].equals("5"))
{
Group5 = true;
}
else if(grp[i].equals("6"))
{
Group6 = true;
}
}
}
}
catch(Exception e)
{
}
%>
<%!
public String sbtvalue(HttpServletRequest request)
{
HttpSession sess = request.getSession(true);
String temp = "0";
if(sess.getAttribute("rtnvalue")!=null)
{
return (String)sess.getAttribute("rtnvalue");
}
return temp;
}
%>
<%!
public String getHolidayID(HttpServletRequest request)
{
HttpSession sess = request.getSession(true);
String tempHolidayID = "-1";
if(sess.getAttribute("HolidayID") != null)
{
tempHolidayID = sess.getAttribute("HolidayID").toString();
}
return tempHolidayID;
}
%>
<%!
public String getHolidayName(HttpServletRequest request)
{
HttpSession sess = request.getSession(true);
String tempHolidayName = "";
if(sess.getAttribute("HolidayName") != null)
{
tempHolidayName = sess.getAttribute("HolidayName").toString();
}
return tempHolidayName;
}
public String getHolidayDate(HttpServletRequest request)
{
HttpSession sess = request.getSession(true);
String tempHolidayDate = "";
if(sess.getAttribute("HolidayDate") != null)
{
tempHolidayDate = sess.getAttribute("HolidayDate").toString();
}
return tempHolidayDate;
}
public String getHolidayCompany(HttpServletRequest request)
{
HttpSession sess = request.getSession(true);
String tempCompany = "";
if(sess.getAttribute("CompanyID") != null)
{
tempCompany = sess.getAttribute("CompanyID").toString();
}
return tempCompany;
}
public String getHolidayDescription(HttpServletRequest request)
{
HttpSession sess = request.getSession(true);
String tempHolidayDescp = "";
if(sess.getAttribute("Description") != null)
{
tempHolidayDescp = sess.getAttribute("Description").toString();
}
return tempHolidayDescp;
}
%>
<form name="holidayDetails" id="holidayDetails" method="post" action="HolidayDetails">
<div class="PageHeaderTitle"> <h2 align="center"> Holiday Details</h2></div>
<div style="vertical-align: super">
<table class="popupTable" cellpadding="10px" cellspacing="10px">
<tbody>
<tr>
<td><label for="lblHolidayName" id="lblHolidayName" >Holiday Name</label></td>
<td><input type="text" name="holidayName" class="textBox" id="holidayName" onkeydown="return isAlphaNumeric(event.keyCode);" maxlength="100" value="<%=getHolidayName(request)%>"/></td>
</tr>
<tr><td><label for="lblCompanyName" id="lblCompanyName" >Company Name</label></td><td><select name="cmbCompany" id="cmbCompany" class="comboBox">
<c:forEach items="${companyList}" var="cmpList" >
<option value="${cmpList}" ${cmpList == selcmbCompany ? 'selected="selected"' : ''}>${cmpList}</option>
</c:forEach>
</select></td></tr>
<tr><td><label for="lblDate" id="lblDate" >Date</label> </td>
<td><input type="text" name="dtpholidayDate" id="dtpholidayDate" value="<%=getHolidayDate(request)%>" class="textBox"/></td></tr>
<tr>
<td><label for="lblDescription" id="lblDescription" rows="4" cols="50">Description</label></td>
<td><input type="text" name="holidayDescription" id="holidayDescription" value="<%=getHolidayDescription(request)%>" class="textBox" /></td>
</tr>
<tr>
<td><input type="checkbox" id ="chckRestrictedGroup" name="chckRestrictedGroup" onclick="disableRestrictedGroup()" <%=restrictedGroup?"checked" : "" %>/> <label for="lblRestrictedGroup" id="lblRestrictedGroup">Restricted Group</label></td>
<td><select name="lstGroup" id="lstGroup" multiple="multiple" class="comboBox" style="height: 80px">
<option <%=Group1?"selected" : "" %>>Group1</option>
<option <%=Group2?"selected" : "" %>>Group2</option>
<option <%=Group3?"selected" : "" %>>Group3</option>
<option <%=Group4?"selected" : "" %>>Group4</option>
<option <%=Group5?"selected" : "" %>>Group5</option>
<option <%=Group6?"selected" : "" %>>Group6</option>
</select>
</td>
</tr>
<tr><td colspan="2"><div class="ButtonDiv">
<input type="button" name="btnSave" value="Save" onclick="save()" class="buttonStyle" />
<input type="button" name="btnCancel" value="Cancel" onclick="cancel()" class="buttonStyle" />
</div><input type="hidden" id="hdtxtcheck" name="hdtxtcheck" />
<input type="hidden" id="txthidden" name="txthidden" value="<%=sbtvalue(request)%>"/>
<input type="hidden" id= "txtHolidayID" name = "txtHolidayID" value="<%=getHolidayID(request)%>"/>
<input type="hidden" id= "selCompany" name = "selCompany"/>
<input type="hidden" id= "selGroup" name = "selGroup"/>
<input type="hidden" id="hdtxtError" name="hdtxtError" value="<%=Error%>"/>
</td></tr>
</tbody></table>
</div>
</form>
</body>
</html>
尝试设置缓存控件标题,以告知浏览器不要缓存页面
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0); // Proxies.
似乎其他浏览器在默认情况下会根据新请求再次检索页面,除非您告诉他们要缓存,而IE在默认情况下倾向于缓存,直到您告诉它不要
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0); // Proxies.