Ways to reload a page using Java script.
When doing web development if you need to reload / refresh a page using Java script, you can use one of the following three methods.
- <script language="javascript" type="text/javascript">
- function ReloadMethod1() {
- window.location.href = window.location.href;
- }
- function ReloadMethod2() {
- window.location.reload();
- }
- function ReloadMethod3() {
- history.go(0);
- }
- </script>
- <input type="button" value="Reload" onclick="window.location.href=window.location.href" />
- <%--Calling Javascript function on button click.--%>
- <input type="button" value="Reload" onclick="ReloadMethod2()" />
- <input type="button" value="Reload" onclick="window.location.reload()" />
- <!-- ASP Buttons -->
- <asp:Button ID="Button1" runat="server" Text="Reload" OnClientClick="window.location.href=window.location.href" />
- <%--Calling Javascript function on button click.--%>
- <asp:Button ID="Button2" runat="server" Text="Reload" OnClientClick="ReloadMethod2()" />
- <asp:Button ID="Button3" runat="server" Text="Reload" OnClientClick="ReloadMethod3()" />