...

View Full Version : multiple function calls from a single js file



Marcus8787
12-11-2007, 08:50 PM
i have 4 images that expand onMouseOver and shrink onMouseOut

<script src = 'js/size.js'>

<div id = 'img1' onMouseOver = \"expand(this.id)\" onMouseOut = \"shrink(this.id)\">
<img src = ...>
</div>
<div id = 'img2' onMouseOver = \"expand(this.id)\" onMouseOut = \"shrink(this.id)\">
<img src = ...>
</div>

etc...

question: when i quickly move the mouse from one image to the other shouldn't i see one expand and one shrink simultaneously?
i am currently seeing one shrink, then the other expand after.
on occasion the shrink is skipped and the next image is expanded right away.

Trinithis
12-11-2007, 09:19 PM
Javascript is a single threaded language, meaning that it can only do one thing at a time. So in your case, the expand function has to finish before the shrink function takes place. The easiest way to create your desired effect probably is to use a sequence of window.setTimeout()'s.

Show your source code (js and html) please so we can help you better.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum