0

I would like a page to force reload once for IE9 users to clear the cache. I've been experimenting with this function:

location.reload();

The question: is it possibly to target people using IE9 and only reload ONCE on load.

Thankful for any help I can get.

/Linus

Linus Josephson
  • 77
  • 4
  • 14
  • why do you want to reload it once only for IE users and how do you want to reload on click or on load and when you press F5 you dont want to reload on IE 9 ?! – shareef Jun 18 '12 at 08:26
  • I wan to reload the page once to delete the cache problem for the IE9 users. I would like to avoid a button and just make it work in the background. If possible that is. – Linus Josephson Jun 18 '12 at 09:51
  • when do you want to relaod page when you first go to page – shareef Jun 18 '12 at 09:59
  • I want the page to reload as fast a possible, directly after the page is loaded in the web browser, but only once. – Linus Josephson Jun 18 '12 at 11:02
  • if you found a way better of the answers let us know so every one can get help of this question – shareef Jun 19 '12 at 05:59

2 Answers2

0

It would probably be best if you could devise some strategy which allows you NOT to depend on the browser version.

Having said that, here is a link that will allow you to detect IE9.

MD Sayem Ahmed
  • 28,628
  • 27
  • 111
  • 178
  • Of course, but in this particular case I have no control over this. We are using Adobe Captivate wich results in that IE 9 users needs to clear cache do get a correct result in the LMS. I'm look for a way so the IE 9 users does'nt need to this manually. – Linus Josephson Jun 18 '12 at 07:03
  • @LinusJosephson: Ok, then you can check the link I have provided with the answer. It shows two simple functions which will tell you how to detect current IE version. You can also use Conditional Comments for this purpose. – MD Sayem Ahmed Jun 18 '12 at 07:09
  • That part I understand, thank you! But I don't se the solution to just reload the page just once! – Linus Josephson Jun 18 '12 at 07:36
0

reference : stackoverflow similar question

from the link to answer taken

Two options:

1- You can use cookies. Set a cookie when logging in and check for that during load. Then clear it after performing your initialization so that next load the check will fail.

2- You can use the address, either as a parameter like ?justLoggedIn, or a value in the hash after #justLoggedIn. Then check for that and redirect to the same url minus the justLoggedIn part. The advantage of the # version is that it doesn't actually reload the page, unlike when using the ? version.

UPDATE: reference :stackoverflow similar question

I'd say use hash, like this:

window.onload = function() {
    if(!window.location.hash) {
        window.location = window.location + '#loaded';
        window.location.reload();
    }
}

UPDATE 2:

i think you should take a look at this question i dont know about pjax until now so i dont know alot about it

stackoverflow question

look at http://pjax.heroku.com/in the answers

Community
  • 1
  • 1
shareef
  • 9,255
  • 13
  • 58
  • 89
  • Problem with the second option: In the '?' version, you cannot use `location.reload(true);` to force a fresh request. So the hash looks more promising here. – Niko Jun 18 '12 at 07:18
  • The page contains a Adobe Captivate webcourse inside a LMS, so I don't really have any freedom besides from editing the single HTML file with inline JavaScript/HTML/CSS-code. – Linus Josephson Jun 18 '12 at 07:42
  • Window.location.hash doesnt work in the lms and generates a an unexpected alert when published. But it does work when I run it local. – Linus Josephson Jun 18 '12 at 14:38