History.go(-1)在IE中不起作用

时间:2022-08-26 15:50:21

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

我有一个返回按钮,我在我的aspx页面中使用了以下代码

<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.

问题是它在Firefox中工作得很好但是当我在IE中尝试它时它无法正常工作。有人可以分享他们的想法。

Update

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

错误地写了return = false;实际代码是:

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

2 个解决方案

#1


7  

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

您引用的代码不应在任何浏览器上运行,它有语法错误(return = false)。最小的变化:

<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.

另请注意,您不需要(也不应该)任何onXyz属性上的任何Javascript:前缀。 onXyz属性中的代码始终是JavaScript,实际上该前缀(在这种情况下)不会触发JavaScript,它会创建一个从未使用过的标签。您可以在需要链接的位置使用javascript:pseudo-protocol,例如元素上的href属性。

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.

旁注:我很久没有做任何ASP.Net了,我完全不确定在相同的输入上运行runat = server和onclick是否合理...如果你想要一个客户端“返回“按钮,删除runat = server。

#2


1  

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;" />

使用返回

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

在任何on ...事件之后你不需要javascript,你只需要在href。在返回时你不需要=。

#1


7  

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

您引用的代码不应在任何浏览器上运行,它有语法错误(return = false)。最小的变化:

<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.

另请注意,您不需要(也不应该)任何onXyz属性上的任何Javascript:前缀。 onXyz属性中的代码始终是JavaScript,实际上该前缀(在这种情况下)不会触发JavaScript,它会创建一个从未使用过的标签。您可以在需要链接的位置使用javascript:pseudo-protocol,例如元素上的href属性。

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.

旁注:我很久没有做任何ASP.Net了,我完全不确定在相同的输入上运行runat = server和onclick是否合理...如果你想要一个客户端“返回“按钮,删除runat = server。

#2


1  

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;" />

使用返回

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

在任何on ...事件之后你不需要javascript,你只需要在href。在返回时你不需要=。