如何在提交表单数据后返回到 html 暂停的视频?
How to go back to video where it was paused in html after submitting form data?
我制作了一个 html 页。并在该视频标签中添加。现在,在视频暂停一段时间后出现一个表单,该表单的数据是使用 servlet 提交的。现在我想回到暂停时的相同视频状态。我应该在 servlet 中使用什么来做到这一点。因为
response.sendRedirect(request.getHeader("referer"));
返回到页面的开头。
已编辑
我在提交表单时正在做这个document.cookie="currentTime=video.currentTime";
,这个
vid.addEventListener("timeupdate", function()
{
if(getCookie("currentTime")!==0){
video.currentTime=getCookie("currentTime");
}
在事件侦听器中,怎么了?
不幸的是,要做到这一点,您无能为力server-side。但是在页面上的 JavaScript 中,您可以将事件处理程序绑定到视频。具体来说,如果您将 progress event, you can keep track of where the user is. You could set a cookie when you get the progress event and overwrite it as the events come in, then when the user goes back to the page, make the video seek 绑定到上次保存的时间。
您可以创建一个不同的 servlet 来捕获表单响应并使用 ajax 提交表单,这将阻止页面刷新,从而保存视频标签中的搜索位置。
我制作了一个 html 页。并在该视频标签中添加。现在,在视频暂停一段时间后出现一个表单,该表单的数据是使用 servlet 提交的。现在我想回到暂停时的相同视频状态。我应该在 servlet 中使用什么来做到这一点。因为
response.sendRedirect(request.getHeader("referer"));
返回到页面的开头。
已编辑
我在提交表单时正在做这个document.cookie="currentTime=video.currentTime";
,这个
vid.addEventListener("timeupdate", function()
{
if(getCookie("currentTime")!==0){
video.currentTime=getCookie("currentTime");
}
在事件侦听器中,怎么了?
不幸的是,要做到这一点,您无能为力server-side。但是在页面上的 JavaScript 中,您可以将事件处理程序绑定到视频。具体来说,如果您将 progress event, you can keep track of where the user is. You could set a cookie when you get the progress event and overwrite it as the events come in, then when the user goes back to the page, make the video seek 绑定到上次保存的时间。
您可以创建一个不同的 servlet 来捕获表单响应并使用 ajax 提交表单,这将阻止页面刷新,从而保存视频标签中的搜索位置。