0

I asked this question before here (HTML5 reload page when moving back), but the responses and answers were getting too messy, so I started fresh. Still don't have it working. Thought I'd ask again.

I'm working with Moodle 2.6, but this isn't really a Moodle question. An activity is defined as an URL. You click on that link for a URL, and it goes to an HTML5 page that is just a custom-built video player. When the video ends, it goes back to the Moodle course page. That all works just fine, but the Moodle page doesn't reflect that this activity has been completed until the page is refreshed/reloaded using F5. Here is the javascript code that I've used to detect the end of the video:

video1.addEventListener("ended", function() {
   history.back(1);
});

I've tried using a number of different variants, such as history.go(-1), etc., but nothing seems to work.

A responder to my previous question suggested using

location.href = document.referrer;

which didn't work. I hard-coded the address that I wanted to return to on the right side of that as a trial, and it seemed to work correctly. I thought that I could just pull the address out of the history buffer, but I can't find a way to access the history buffer strings directly so that I can use them.

So, is there a way to access the history buffer URL strings, or do you have a better suggestion on how to go back to the previous page AND refresh/reload this page. I can get it to go back, but it won't refresh. I'm mainly using IE on the PC, and Safari on the iPad.

Thanks, Bill

Community
  • 1
  • 1
user2574497
  • 3
  • 2
  • 6
  • I believe this should help, regarding using the unload event - cached pages are usually loaded when navigating back through the browser history: http://stackoverflow.com/questions/158319/cross-browser-onload-event-and-the-back-button/170478#170478 – athms Mar 03 '14 at 14:13

1 Answers1

0

The answer ended being that documnet.referrer didn't have a value when I tried to use it, so I had to grab the document.referrer value in my onload event and save it.

var myReferrer = document.referrer;

When the video finished, I was able to use it like this:

window.location.href=myReferrer;

Thanks so much for everyone that helped here and previously.

user2574497
  • 3
  • 2
  • 6
  • Glad you found it. Please mark this question as answered as well as the previous one (Bruno's answer was correct after all). – Patrick Hofman Mar 03 '14 at 22:27