How can I have my javascript code constantly run? The situation is that I want some page elements to be resized when the page resizes. I’m thinking that the way to do this would be to have some javascript code that constantly runs, and whenever the page size changes, it resizes that element.
I tried doing this with setTimeout() and a really small value, but it didn’t seem to work.
How can I have my javascript code constantly run? The situation is that I
Share
JavaScript is an Event based language, that is you add event listeners to things and then a function is called when that event occurs. This saves you from having a loop run continuously to to check the state of an item.
The window supports onResize in JavaScript, so for example: