[英]How can I back to previous page using angular tab in asp.net
I want to go back to the previous page when the user clicks the back button but my current code didnt do anything means the page is not redirecting my current code is give below 当用户单击“后退”按钮时,我想返回上一页,但是我当前的代码没有做任何事情,这意味着该页面未重定向我的当前代码如下
<a href="#" onClick="goBack();" <i class="icon-white icon-chevron-left"></i></a>
function goBack()
{
window.location.href =document.referrer;
}
any thoughts???? 有什么想法吗????
You could leverage session history management: 您可以利用会话历史记录管理:
window.history.back()
Note that this is supported in all major browsers, except IE 9 and below. 请注意,除IE 9及以下版本外,所有主流浏览器均支持此功能。
This works for me. 这对我有用。 Your JavaScript may not be loading before your HTML is.
您的JavaScript可能无法在HTML之前加载。
Another thing: it is considered 'bad practice' to tie JavaScript functions to HTML elements. 另一件事:将JavaScript函数绑定到HTML元素被认为是“不好的做法”。 You could try, instead:
您可以尝试以下方法:
HTML 的HTML
<a id="goBackLink" href='#'>...</a>
JavaScript 的JavaScript
$('#goBackLink').click(function() {
window.location.href = document.referrer;
}
Of course, this means using the jQuery library. 当然,这意味着使用jQuery库。 If you don't want to use the jQuery library your function would instead look like:
如果您不想使用jQuery库,则函数应如下所示:
document.getElementById('goBackLink').onclick = function() {
window.location.href = document.referrer;
}
Which I think should work. 我认为应该起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.