![]() |
| ||
| Multiple Mouseover Events How do I have multiple mouseover events at the same time? Here's what I have so far. <a href="assets/Ads/agapeCreations.pdf" /> I have the images swapping fine, but the self.status isn't working. |
| ||
| Re: Multiple Mouseover Events Inline javascript code is really not recommended. Firstly it is difficult to maintain since it clutters the already cluttered markup. Secondly, it absolutely lacks the separation of logic and presentation, something which you should definitely try to achieve always. Thirdly changing the logic may require changing the code at multiple locations. Having the functionality packed up or encapsulated inside a single function is much recommended. Attach a listener to your onmouseover event handler to do the required job for you and encapsulate your image swapping logic in that listener. |
| ||
| Re: Multiple Mouseover Events Hmm. I'll have to do some looking up on listeners. I've not heard of them before. I'm obviously quite new to JavaScript though. Thanks! |
| ||
| Re: Multiple Mouseover Events try window.status='' instead |
| ||
| Re: Multiple Mouseover Events From what I've been able to see, listeners aren't supported thoroughly yet. Are they a good universal thing to use right now? Also, I've changed what I'm trying to accomplish. I'm trying to get the images to swap out when the mouse is rolled over. I'd really rather not have to use a mousedown. But this mouseover doesn't seem to be working for me: <a href="assets/Ads/agapeCreations.pdf" |
| ||
| Re: Multiple Mouseover Events > From what I've been able to see, listeners aren't supported thoroughly yet. Are they a > good universal thing to use right now? There are two ways of attaching a listener to an event handler of an HTML element. One is to directly assign a function to that event handler which would then act as a listener. An example would be: window.onload = function() {
The disadvantage here is that you can't attach multiple event handlers to the listener in a clean and simple manner since assigning another listener would result in the previous one being erased.Another way is to use the functions provided by the event object such as attachEvent[IE only] or addEventListener [Gecko based browsers]. So, in a sense you are right in saying that the listener function is not supported by non-Gecko browsers like IE. Here I would be presenting a simple wrapper which would attach events in a almost transparent manner and should work on almost all browsers out there. /** And oh, BTW, you don't need Javascript to get the rollover effect. It can be done very well achieved using a pure CSS solution. |
| ||
| Re: Multiple Mouseover Events Okay, but for curiosity's sake, if I were to use JavaScript for the rollover effect, would the above be correct? |
| ||
| Re: Multiple Mouseover Events The problem is that you are trying to access the srcproperty of the anchor ( <a>) element instead of the image element. Move the mouseover and mouseout declarations from the <a>tag to the <img>tag and it should work out to be fine. But then again, it's not the best of methods, you have been warned. |
| All times are GMT -4. The time now is 1:26 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC