向后移动HTML5重新加载页面 [英] HTML5 reload page when moving back

查看:262
本文介绍了向后移动HTML5重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Moodle 2.6,但这并不是一个真正的Moodle问题。活动定义为URL。该URL只是一个定制的视频播放器。视频结束后,将返回到Moodle课程页面。一切正常,但 Moodle页面在使用F5刷新/重新加载页面之前并不表示该活动已完成。这是我用来检测视频结尾的JavaScript代码:

I'm working with Moodle 2.6, but this isn't really a Moodle question. An activity is defined as an URL. That URL 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 this:

    window.location.reload(history.go(-1));

代替了history.back(1),认为这条新线充满了希望,但没有喜悦。我也尝试过其他方法,例如将 back更改为 go(值为负数),但这似乎功能相同。

in place of the history.back(1), thinking that this new line held a lot of promise, but no joy. I've tried other things as well, such as changing 'back' to 'go' (with the negative of the value), but that appears to function the same.

这似乎应该是一件简单的事情,但是我对这方面不是专家,所以我很沮丧。如何使浏览器返回页面然后重新加载?我主要在PC上使用IE,在iPad上使用Safari。

This seems like it should be a simple thing to do, but I'm no expert on this stuff, so I'm stumped. How do I get my browser to go back a page then reload it? I'm mainly using IE on the PC, and Safari on the iPad.

EDIT,其他想法

当我对此进行研究时,一个建议是在URL的末尾添加一个唯一的ID,例如使用时间。因此,就我而言,我想从-1条目的历史记录缓冲区中提取URL,并添加?123456之类的内容(每次都会更改),然后调用该页面。

When I was researching this, one suggestion was to add a unique ID at the end of the URL, such as using the time. So, in my case, I'd want to pull the URL out of the history buffer for the -1 entry and add something like ?123456 (which changes every time), then call that page. Is something like that a good idea, good coding standards, etc?

推荐答案

正确的解决方案是设置您的网址, d想推荐用户。

The right solution would be setting up the URL you'd like to refer the user to.

如果您无法做到这一点,并回答您的问题,则可以尝试使用location.href将用户重定向到推荐人页面。 :

If this is not possible for you, and answering your question, you can try redirecting the user to the referrer page using location.href:

location.href = document.referrer;

这会将用户重定向到他们来自的页面,浏览器不会尝试还原页面的先前状态。

This will redirect the user to the page they came from, and the browser won't try to restore the previous state of the page.

这篇关于向后移动HTML5重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆