var startTime = Math.ceil(new Date().getTime()/1000)//单位秒
var play_time = ""
//获取视频标签播发时间
$('#video-active').on("timeupdate",function(event){
var all_time = this.duration
play_time = this.currentTime
})
//初始化时间
getDuration = function(){
var time = '',
hours = 0,
minutes = 0,
seconds = 0,
endTime = Math.ceil(new Date().getTime()/1000),
duration = endTime - startTime
if(play_time){
duration = play_time
}
// var g_time = ""
var dt = localStorage.getItem("param")
if(dt == null || dt == "" || dt == undefined){
localStorage.setItem("param", duration)
// data = param
}else{
duration = duration + parseInt(dt)
}
localStorage.setItem("param", duration)
hours = Math.floor(duration/3600)//停留小时数
minutes = Math.floor(duration%3600/60)//停留分钟数
seconds = Math.floor(duration%3600%60)//停留秒数
time = (hours <10 ? '0' + hours : hours) + ':' + (minutes <10 ? '0' + minutes : minutes) + ':' + (seconds <10 ? '0' + seconds : seconds)
$.ajax({
type: "POST",
url: "url",
data: {time: time,id: id,play_time: play_time},
success: function(data) {
console.log(data)
},
error: function() {
}
})
}
//监听窗口关闭事件
window.onbeforeunload = function(e){
var duration = getDuration()
//request(duration)
}
})()
</script>
<html><head>
<script language="javascript">
function showtime()
{
document.write(t)
t = t - 1000
if(t==0)
{
window.close()
}
}
</script>
<SCRIPT LANGUAGE=javascript>
<!--
waitTime=3000//10 秒
timer=setInterval("OnTimer()",1000)
function OnTimer(){
waitTime=waitTime-1000
if(waitTime==0){
document.write('网页内容2')
}
txtTimer.value="停留" + waitTime / 1000 + "秒"
}
//-->
</SCRIPT>
</head>
<body>
<SCRIPT LANGUAGE=javascript>
<!--
document.write('网页内容1<br>')
document.write('<input name=\"txtTimer\" value=\"停留' + waitTime / 1000 + '秒\">')
//-->
</SCRIPT>
</body>
</html>
------解决方案--------------------那要设置页面接收页面的页数
才返回
或者js实现也可以
------解决方案--------------------
修改过后不跳转不就好了?
------解决方案--------------------
2个方法,1,用ajax,最好的,2,当你更新成功以后,再次访问你的serlvet或者action,返回你页面需要的查询结果
------解决方案--------------------
得到当前页,把当前页传给你分页的servet或者anction,返回当前页的数据