Using javascript for pinging a webapp to keep session open

前端 未结 6 718
一个人的身影
一个人的身影 2021-01-31 10:26

I\'m writing a greasemonkey script to keep session open on a webapp I use for work. Which javascript command would you use to create some feedback with the server and ensure the

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-31 11:07

    If you want to write JavaScript to solve this (the other answers are a lot easier and I would recommend going the easier route), here's what I would do:

    • Call document.createElement("iframe") to create an iframe
    • Size the iframe to 0x0, style.display = "none", set the ID to something, and set the src property to a page on the site that will extend your session
    • Use document.body.appendChild to add the iframe to the page
    • Using setTimeout refresh the iFrame using window.frames['iframeID'].location.reload(true); and also call setTimeout to refresh the page again.

    See if the other answers would work because using JavaScript seems like it would be more trouble than it's worth.

提交回复
热议问题