[英]I want to click on divs link and open info on other div within same page
[英]I want to record the time when I click on the link and end the record from when I click on the other link on the other page
第一个链接:
<td style="text-align: center;>
<font size="1">
<a href="Evaluation_Form.php?id=<?php echo $row_member['id']; ?>" target="_blank">Evaluate</a>
</font>
</td>
第二个链接/按钮:
<input type="submit" name="register" class="btn btn-info" value="Submit" />
对于时间最简单的方法是使用Linux TIMESTAMP,它是一个几秒的整数,因此比使用数学基础60和12/24的其他日期更容易管理和操作。 在SQL中你有CURRENT_TIMESTAMP()或NOW(),在JavaScript中你可以使用Date对象这样的
var timestamp=new Date().getTime();
所以做两次并将第二次减去第一次并且你将有持续时间(或者如果数据库需要它保持2个时间戳注册)。
编辑:您可以使用函数time()来获取PHP时间戳,记住服务器的时间而不是用户的本地时间。
您可以在PHP中创建后端API以节省在页面中花费的时间,如下所示,它不依赖于哪个页面,仅基于就绪页面和卸载页面进行计算。
$(document).ready(function() {
var startPage = new Date();
$(window).unload(function() {
var leavePage = new Date();
var page = (location.pathname+location.search).substr(1);
$.ajax({
type: 'POST',
url: "/api/stayonpage",
data: {'timeOnPage': leavePage - startPage, 'page' : page },
contentType: 'application/json; charset=utf-8',
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.