Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect client-side when a page load is the result of an AJAX history point?

I'm trying to prevent a "flicker" effect that is occurring on my ASP.NET page which occurs when a user navigates to the page via the browser back button after having navigated away from it. The reason for the flicker is that I'm using an Update Panel which has some content in there on the initial page-load. As a result, when the page is loaded via a back button that initial content is shown very briefly before it is updated with the correct History-aware data.

In order to overcome this I am intending on having the updatepanel hidden (display: none) on inital page load and then show it as long as we don't have any history to deal with. The problem is that I can't find out what to check to determine if there's any history. I can see that the Sys.Application has a _history member but when I'm checking it on page init it is null each time.

Does anyone know what I should be checking to determine if there's history to deal with for a page load client-side? And at what point to do it?

like image 431
Nick Avatar asked Nov 15 '22 10:11

Nick


1 Answers

The browser's back button and the functionality that it provides is completely independent of the content of your web page.

One thing you might be able to do is set your location hash when you do an AJAX update. You might be able to detect this when you load a page. I haven't tried it. You should be able to parse out the # portion of the url on the Server Side and see where you are in the AJAX history.

location.hash = 'foo';
like image 195
Daniel Dyson Avatar answered Dec 09 '22 18:12

Daniel Dyson