admin管理员组

文章数量:1185719

hi I have an asp button which is created using the following code:

<asp:Button ID="btnBack" OnClientClick='javascript:history.back()' runat="server" Text="back">
</asp:Button>

However, now the javascript doesn't work to go a history back. On the other hand, if I make an alert() it works...why. Why is it not working to go a history back?

hi I have an asp button which is created using the following code:

<asp:Button ID="btnBack" OnClientClick='javascript:history.back()' runat="server" Text="back">
</asp:Button>

However, now the javascript doesn't work to go a history back. On the other hand, if I make an alert() it works...why. Why is it not working to go a history back?

Share Improve this question edited Jan 4, 2018 at 16:45 Jongware 22.4k8 gold badges55 silver badges101 bronze badges asked Dec 17, 2009 at 14:16 MarcMarc 2,8593 gold badges36 silver badges43 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 26

Try with return false at end:

 <asp:button id="btnBack" runat="server" text="Back" 
OnClientClick="JavaScript: window.history.back(1); return false;"></asp:button>

Try:

parent.history.back();

Or

history.go(-1)

Had the same problem in DevExpress project. Using ASPxButton without initializing the property "AutoPostBack" will result in redirect to self page before any client-side function call. Try AutoPostBack="false" for the button.

本文标签: javascriptasp button and history back onclientclickStack Overflow