Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

javascript - Javascript / Jquery-在关闭浏览器窗口后的几秒钟内保持会话(Javascript/Jquery - Keep session in seconds after browser window closed)

Is there any possible to track no.

(有没有可能追踪没有。)

of seconds user was on our webpage after they closed browser window or tab?

(用户关闭浏览器窗口或标签后进入我们网页的秒数?)

We need to add a cookie after they click close window/tab.

(他们单击关闭窗口/选项卡后,我们需要添加一个cookie。)

From there, we can track how much seconds they are away?

(从那里,我们可以追踪到他们有多少秒?)

If user came back or restore window after 10 mins.. we need to redirect user to particular page.

(如果用户在10分钟后返回或恢复窗口,则需要将用户重定向到特定页面。)

Tried below code, to track close function.. not some how its not working as expected.

(尝试过下面的代码,以跟踪关闭功能..尚无法正常运行。)

 window.onbeforeunload = function (event) { var message = 'Important: Please click on \'Save\' button to leave this page.'; if (typeof event == 'undefined') { event = window.event; } if (event) { event.returnValue = message; $.cookie('cookiesession', true, { path: '/', expires: 80000, secure: window.location.protocol.indexOf('https:') != -1 }); } return message; }; 

Thanks

(谢谢)

  ask by TDG translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...