function visit_timing()
{
var start;
var end;
var duration = 0;
start = new Date();
$(window).bind('beforeunload', function(e) {
end = new Date();//用户退出时间
duration = end.getTime() - start.getTime();
duration = duration/1000;//取的是秒
$.ajax({
type: 'POST',
async: false,//这块至关重要,用$post默认是true
url: 'url',
data: {a:1.vid,b:duration}
});
});
}