关于javascript:popup在Internet Explorer中第二次加载时不加载jsp脚本

popup not load the jsp scripts while loading second time in Internet Explorer

我创建了一个网页,其中包含具有父级和子级格式的JSP页面。当我使用JavaScript的ShowModalDialog函数单击以弹出方式加载子JSP页面时。当弹出页面在除IE之外的所有浏览器中调用时,它都会在客户端页面中运行JSP脚本。在IE中,JSP脚本只在第一次运行,下次不运行JSP脚本。事先谢谢。请按需要做。抱歉我英语不好。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<%@ 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">

<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 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 type="text/javascript" src="JQuery/jquery-ui-1.10.3/ui/jquery-ui.js">
   

<script type="text/javascript" src="JS/HolidayDetails/HolidayDetails.js">
Precision Attendance
</head>
<body onloadx="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">
   <h2 align="center"> Holiday Details

<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">
<input type="button" name="btnSave" value="Save" onclick="save()" class="buttonStyle" />&nbsp;
<input type="button" name="btnCancel" value="Cancel" onclick="cancel()" class="buttonStyle" />
<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>

</form>
</body>
</html>

以及在弹出窗口中调用页面的javascript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function Add()
{
    try
    {          
        holidayList.hdtxtcheck.value="1";
        var answer = window.showModalDialog("HolidayDetails.jsp","precision","dialogWidth:600px; dialogHeight:500px; center:yes");
        holidayList.submit();
    }
    catch(ErrorMessage)
    {
        alert(ErrorMessage);
    }
    return;    
}

尝试设置缓存控制头以告诉浏览器不要缓存页面。

1
2
3
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则倾向于在默认情况下缓存,直到您告诉他们不要缓存为止。