Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE8 only jumps back to top of previous page not where I was before (but only with JS on)

I have a horrible, scattered page with lots of JavaScript:

It has a list view and if you like you can watch one of the items in the list in detail.

The problem is now if I want to go back from the details view to the list view by using the browser back button I get different results.

In Chrome and Firefox, even in IE7 I will end up where I clicked, but not so in IE8.

To make it even more confusing, if I switch JavaScript off it works for IE8 as well.

The problem is now I don't now where to search. Does somebody know this problem or at least a JavaScript method or function which could affect this?

like image 449
lony Avatar asked Apr 18 '13 16:04

lony


1 Answers

It is difficult to provide a definitive answer without the code. A tentative answer based on past experiences with IE:

IEs have different behaviors, especially IE8 which is at the crossing of the old and all but standard versions [IE6-, IE7] and the newer IE9 that better sticks to standards. In particular in Javascript, IEs may be picky compared to non-IE browsers.

That back behavior could happen if a JS error is triggered either when you leave the page (thanks to the link click), or when you come back (which is easier to spot)

  • Check if an error occurs when leaving (or coming back) at the bottom of the page
  • The click action could be delayed thanks to setTimeout which function would set window.location.href to give you enough time to spot an error before the page is left
  • If the redirect is "manual" (like window.location.href= as opposed to a simple <a> tag) Try to add a try {} catch around the code that run after the element is clicked (like with this onbeforeunload bug).
like image 110
Déjà vu Avatar answered Nov 14 '22 23:11

Déjà vu