Is there a jquery function that can return the method used to navigate to the page? I am specifically looking for way to tell if the use pressed the back button.
Asked
Active
Viewed 70 times
0
-
"to load additional content into my web page" This is syntax for onload event, not ajax wrapper load method. Any way we can check your issue online? – A. Wolff Mar 27 '14 at 19:16
-
"This has do do mainly with forms and repopulating the info in them." So i guess you submit the FORM, using default behaviour, right? AFAIK, some browsers will keep all datas filled in input FORM, some other won't. Now how is it relevant to onload event of window object? – A. Wolff Mar 27 '14 at 19:28
-
Well looks like your issue comes form the timeout or whatever you use to delay your logic. Again, without seeing what you are doing, i guess no one could help you more... And be aware, once page is unloaded, no more script is executed in the background regarding this old page, so "unless the back button is hit within 10 seconds of the page load" is wrong guessing – A. Wolff Mar 27 '14 at 19:38
-
I'm asking the question wrong... Let me change it – Hoytman Mar 27 '14 at 19:47
-
Following your edit, no there is not! But maybe there is some specific workaround to get the behaviour you wish. I understand you don't want to share your actual code but you should in order to letsomeone be able to check what is wrong in your code. BTW, you could use persistent storage as cookie/local/session storage to check if user has already done ajax request in past x minutes, etc... – A. Wolff Mar 27 '14 at 19:52
-
The code is a bit cumbersome, probably more than it needs to be (it spans several files) and there is a security issue. I am using persistent storage, but it is deleted every ten seconds. I'll just change this from 10 seconds to 20 minutes. That will solve my problem. Could you state you last comment as an answer? – Hoytman Mar 27 '14 at 19:58
1 Answers
0
You may also try :
$(window).bind("unload", function() { /* .... */ });
or
$(window).unload(function(){ /* ... */});

Anthony Raymond
- 7,434
- 6
- 42
- 59
-
-
@Hoytman It is supposed to be fired when user leave the current page and usually better is to use onbeforeunload. Now i don't see how this can adress your issue, maybe Anthony could elaborate on this. But again, could you provide a sample of your issue because using back button, previous page shouldn't have any content removed. So what is your issue??? – A. Wolff Mar 27 '14 at 19:22
-
@Hoytman Sounds like you need to have a body like this : when you use unload. Source : http://stackoverflow.com/questions/158319/cross-browser-onload-event-and-the-back-button – Anthony Raymond Mar 27 '14 at 19:31
-
I updated the question with a better description, but I doubt that there is an easy workaround. – Hoytman Mar 27 '14 at 19:36
-
@A. Wolff indeed it is, but i do not think that the content is outdated – Anthony Raymond Mar 27 '14 at 19:36