javascript - JQuery - Run once per session -


I have a function triggered by the "calculation" button

I just need this line Once per session (session can be 1 day or until browser is reloaded).

  $ ('popup-to-form'). MagnificPopup ('open');  

This opens a magnificent popup. Once this function is executed (popup opens), if the "count" button is pressed again, then I do not want to open the popup again.

JS / JQuery code:

function stateChanged () {if (XmlHttp.readyState == 4 || XmlHttp.readyState == "full") {$ (' .popup- with form ') magnificPopup (' open '); Document.getElementById ("CalcSum"). InnerHTML = XmlHttp.responseText; Document.getElementById ("CalcSumPopup"). InnerHTML = XmlHttp.responseText; }}

PS I know that many of these questions have popped up, and I tried various ways of working, but since I " Code-invoice "and do not know JQuery or JS I can not understand it I know that in JQ there is a .one "thing", but it does not understand how it works.

I really appreciate any help. Thanks!

UPDATE question @ MarcoBonelli answered - thank you!

Work Solution:

  if (! SessionStorage .alreadyClicked) {$ (popup-with-form ') MagnificPopup ('open'); SessionStorage.alreadyClicked = "true"; }   

If you want to execute this line, then each browser Only once in the session you sessionStorage .

Then you can do something like this:

pre> if (! SessionStorage.alreadyClicked) {$ ('popup -k-form '). MagnificPopup ('open'); SessionStorage.alreadyClicked = 1; } Be careful with

sessionStorage as it can only store string values.

If you want a line, the session per page will be executed only once (which means that after each page is refreshed), then you can use any variable and to really set it You may remember that you have already performed the line:

  if (! Already selected) {$ ('. Popup-of-form'). MagnificPopup ('open'); Already tight = true; }  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -