0

how to make it so that after 5 minutes of inactivity a window appears on the site, in which it was written that the prices are outdated and there was a button to refresh the page? The window should only appear if there is no action on the page (scrolling, clicks, typing are actions) Thank you in advance.

Arcadiy
  • 93
  • 6
  • Please visit [help], take [tour] to see what and [ask]. Do some research, ***[search for related topics on SO](https://www.google.com/search?q=javascript+popup+inactivity+site:stackoverflow.com)***; if you get stuck, post a [mcve] of your attempt, noting input and expected output, preferably in a [Stacksnippet](https://blog.stackoverflow.com/2014/09/introducing-runnable-javascript-css-and-html-code-snippets/) – mplungjan Sep 17 '21 at 14:40
  • 1
    So prices change if your visitors are inactive for a certain amount of time, but not if they stay active? Seems like a bad approach to the problem. You should instead use Ajax and have it update the prices live without the need of user interaction. – icecub Sep 17 '21 at 14:42
  • @MontanaBurr We're not here to judge people's intentions though. Neither of us knows what it's all about. Could simply be some type of browser based game and we're not even talking real currency here. – icecub Sep 17 '21 at 15:06
  • @MontanaBurr The site is dedicated to the prices of air tickets. On the main page of the site, there is a block with prices tied to the city of the visitor, there is no such possibility to show price changes in real time, but a person must indicate that prices are not relevant at the moment, that the page needs to be refreshed. – Arcadiy Sep 17 '21 at 15:07
  • @icecub The site is dedicated to the prices of air tickets. On the main page of the site, there is a block with prices tied to the city of the visitor, there is no such possibility to show price changes in real time, but a person must indicate that prices are not relevant at the moment, that the page needs to be refreshed. – Arcadiy Sep 17 '21 at 15:07
  • @Arcadiy Of course it's possible to change prices live if they change with a page refresh. All you need is Ajax (Asynchronous Javascript and XML). Javascript simply requests the new prices from the server, waits for a response and updates it on the website without needing to refresh. You don't need to install anything special for this. It's pretty basic – icecub Sep 17 '21 at 15:10
  • @icecub This option would also be good. A layer would be superimposed on top of the block, this block would be blurred, and on top of the inscription "ticket prices are not up-to-date, please refresh the page", and in the middle there is an update button – Arcadiy Sep 17 '21 at 15:11
  • @Arcadiy so whoever owns this Website is just showing the current airline price? As in, if I log in right now and punch in a route, I see the same price as those who searched for the same route 5 minutes before but went inactive for 5 minutes (assuming we're seated in the same class on an airplane)? –  Sep 17 '21 at 15:12
  • @MontanaBurr A person could go to the main page, walk on it, then go to any other. During this time, prices could have changed, he decides to go back and open a tab in the browser of the main page and clicks on the ticket on the main page, which has already changed the price during this time and this is very bad. – Arcadiy Sep 17 '21 at 15:17
  • Anyway, what exactly is it that you expect from us? You're not showing any of your code. You're not showing anything that you've tried yourself to solve the issue. All you do is basically tell us what you want. Stack Overflow is not the place to find tutorials or free programmers to do your job for you. It's a community to get help with problems you're having with _your_ code. – icecub Sep 17 '21 at 15:17
  • @icecub I get prices from API using a multi-query, how to change them in real time. Are there any examples of this kind of API working in real time without reloading the page? – Arcadiy Sep 17 '21 at 15:20
  • @icecub Could you give a link or a search query from Google, with a correctly formulated question, I'm afraid I might get it wrong and I won’t find the information? thanks – Arcadiy Sep 17 '21 at 15:21
  • I've told you 2 times already: Ajax. Just type it in Google "Javascript ajax". There's tons of websites explaining it and showing you examples of how it works. If you're familiar with Javascript, it should be pretty simple to figure out. – icecub Sep 17 '21 at 15:23
  • @icecub Thank you – Arcadiy Sep 17 '21 at 15:24

0 Answers0