简体   繁体   中英

History.go(-1) not working in IE

I have a go back button and i have used the following piece of code in my aspx page

<input type="button" runat="server" value="Back" onclick="Javascript:history.go(-1); return=false;" />

The prob is its working fine in Firefox but when i am trying it in IE its not working. Can someone share their Idea.

Update

By mistake I write return=false; the actually code is:

<input type="button" runat="server" value="Back" onclick="Javascript:history.go(-1); return false;" /> <input type="button" runat="server" value="Back" onclick="Javascript:history.go(-1); return false;" /> and still not working.

Your quoted code shouldn't be working on any browser, it has a syntax error ( return=false ). With minimal changes:

<input type="button" runat="server" value="Back" onclick="history.go(-1); return false;" />

Also note that you don't need (and shouldn't have) any Javascript: prefix on any onXyz attribute. The code in onXyz attributes is always JavaScript, and in fact that prefix (in that situation) doesn't trigger JavaScript, it creates a label that's never used. You use the javascript: pseudo-protocol in places where a link is expected, such as the href attribute on an a element.

Side note: I haven't done any ASP.Net in a long time, I'm not at all sure it makes sense to have runat=server and onclick on the same input ... If you want a client-side "Back" button, remove runat=server .

Use <a href="Javascript:history.go(-1); return false;">Back</a> or <input type="button" runat="server" value="Back" onclick="history.go(-1); return false;" /> <input type="button" runat="server" value="Back" onclick="history.go(-1); return false;" />

After any on... events you need no javascript , you need it only at href . And at the return you need no = .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM