views:

229

answers:

2

hi I have an asp button like this

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

now the javascript doesn't work to go a history back. but if I make an alert() it works...why

how to solve this?

thank you

+2  A: 

Try with return false at end:

 <asp:button id="btnBack" runat="server" text="Back" 
OnClientClick="JavaScript: window.history.back(1); return false;"></asp:button>
TStamper
wow! it works! why that? Thank you really much.
snarebold
asp:button will do a postback, so return false on your javascript prevents that postback
TStamper
seems to make logic:)... thanky you.
snarebold
A: 

Try:

parent.history.back();

Or

history.go(-1)
graphicdivine