如何通過使用IE的Java腳本,下面的代碼是工作在Mozilla,但無法在Internet Explorer刷新頁面如何刷新頁面,在IE
- window.location.reload());
- history.go(0);
如何通過使用IE的Java腳本,下面的代碼是工作在Mozilla,但無法在Internet Explorer刷新頁面如何刷新頁面,在IE
Window.location.href是窗口頁面的網址。你做什麼,只是重寫非常相同的值,所以瀏覽器發送另一個GET請求,同樣的烏爾
window.location.href = window.location.href;
可能會添加一些解釋至於發生了什麼 – 2012-08-03 05:04:58
Window.location.href是窗口頁面的網址。你所做的只是重寫相同的值,所以瀏覽器發送另一個GET請求到同一個url。 – 2012-08-03 05:06:55
window.location = window.location
使用window.location.reload(true);
使用本:
location.reload();
它應該工作。如果它不起作用,您的頁面中可能會出現其他錯誤。
在javascript中您可以使用:
location.reload(); => post request, same as click the refresh button on the browser
window.location=window.location; => get request
self.location=self.location; => get request
如果你得到一個IE錯誤說
「要再次顯示該網頁時,Internet Explorer需要重新發送您先前提交的信息」,
你可以使用window.location = window.location;刷新頁面而不是location.reload();
實現:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="PostMethod_Test._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Literal ID="litJavascript" runat="server"></asp:Literal>
<div>
Refresh:
<div>
Get/Post Method:<a href="javascript:location.reload();">JS Location Reload</a> (if
there is any control in the form then after the form was submitted for the first
time, if you click this, it will be a post method coming with the IE alert)
</div>
<div>
Get Method:<a href="javascript:window.location=window.location;">JS Window Location</a>
(does not create a history entry) (if there is any control in the form then after
the form was submitted for the first time, if you click this, it will still be a
get method which means the form will not be submitted again)
</div>
<div>
Get Method:<a href="javascript:self.location=self.location;">JS Self Location</a>
(Same as above)
</div>
<div>
Get/Post Method: IE Refresh button - same as location.reload()
</div>
</div>
<hr />
<div>
Open New Window:
<div>
No Method:<a href="javascript:var a = window.open('webform1.aspx');">JS Window Open</a>
(just open)
</div>
<div>
Post Method for parent page:<asp:Button ID="btnOpen" Text="Open Window" runat="server" />
</div>
</div>
</div>
</form>
</body>
</html>
你得到任何工作的答案嗎? ..嘗試所有下面的答案,但沒有工作。 – NMathur 2017-09-23 09:07:58