Question

I have Close button on my ASP.NET MVC page. I wrote the following code to go back to previous page. It is working fine in IE9 but throwing error in IE8.

 $('#Close').click(function () {
          window.location.href= '@Request.UrlReferrer';

        });

Appreciate your responses.

Thanks

Was it helpful?

Solution

Referer is not required by the HTTP specification, so you can't really rely on it. You can use this though

$('#Close').click(function () {
  window.history.back();
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top