Jump to content

JavaScript SetInterval(); question

robeng
Go to solution Solved by SCHISCHKA,

use the resize event in the body tag:

http://www.w3schools.com/jsref/event_onresize.asp

<body onresize="myFunction()">

yes it does have a negative. for an example of what it can do, load up any news website or blog overloaded with advertising.

Hi! in my site I have a javascript code that sets the "top:" property for an element so it stays in the middle of a picture. If you resize the window the text does not stay in the middle. The only way I figured out was right to do was to create a SetInterval("functionName",1);

so every millie second it sets the text in the middle. This looks kind of smooth but I wonder if this will have some negativ effects on the website(like: additional lag, performence drop etc)?

Thanks in advance!

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×