简体   繁体   English

我如何使用asp.net中的角度标签返回上一页

[英]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.

相关问题 如何在ASP.NET中使用Javascript返回上一页 - How to go back to previous page using Javascript in ASP.NET 如何在保留上一页数据的同时返回asp.net中的上一页 - How to go back to previous page in asp.net while retaining the previous page data 在ASP.Net中打开弹出页面后,如何返回上一个窗口页面? - How to go back to previous window page after opening a pop-up page in ASP.Net? 用户使用JQuery切换到Asp.net文本框值时,如何用它替换以前的asp.net文本框值? - How can I fill an asp.net textbox with a previous asp.net textbox value when the user tabs to it using JQuery? 在ASP.NET中注销后如何阻止/阻止用户返回上一页 - How to block / prevent user to go back to previous page after logout in ASP.NET 如何防止用户返回 ASP.NET 中的上一页 - How to prevent user from going back to previous page in ASP.NET 使用 Asp.Net Core,如何将视图作为新的浏览器选项卡打开,然后稍后再关闭 - Using Asp.Net Core, how can I open a view as a new browser tab, and then close it again later 单击asp.net中的上一个按钮后,如何进入asp.net中的上一页 - how to go previous page in asp.net after clicking previous button in asp.net 如何在ASP.NET页中实现倒数计时器? - How can I implement a countdown timer in an ASP.NET page? 如果可能的话,可以使用Mailto链接将当前页面添加到Outlook邮件正文中吗? 在asp.net - Using Mailto link can I add the current page in the outlook mail body if possible then how ? in asp.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM