• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

setTimeout based on a URL load time

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm working on a website, where an internal Search page will be under maintenance for a couple days.

Is there a way that I can display an alert if the page is taking longer then 5 seconds to load?

What I'm thinking is something along these lines:

try for 5 seconds
if not able to get to example.com
alert(search borken)
else
do whatever

is setTimeout something that can be used for this?




 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can't get to the page, how could you set a timeout on it?
 
casey Gould
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, yeah that's what I was thinking to begin with. I just wanted to check the load time so that I can have an alert pop up.

So i decided to go maybe this route

So what I'm trying to do is, if the input filed is empty return false.

If the input value is true than check the loadtime, if the load time is longer than x amount stop the form from submitting.

I'm not sure if my logic is even correct.

What I initially intended with the load time is if longer then x amount display error but don't run the code.

Original code



GenSearch = Submit Button name
q = input filed name



Hope this makes some since
 
casey Gould
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so I believe I have fixed the issue

using below code



Bear, Thanks for the input on not using setTimeout. Pointed me in the right direction to go a different route
 
Looky! I'm being abducted by space aliens! Me and this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic