1 reply [Last post]
ga_acad
ga_acad's picture
User offline. Last seen 7 years 27 weeks ago. Offline
newbie
Joined: 2004-08-02
Posts: 1
Points: 0

Newbie here. Hope this is the right forum to post this in.

I use the <a href=".." OnMouseOver="beep()"> method to
beep a certain sound when the mouse passes over the links. However, if I have a thousand links in one page, or if the links keep changing over time (perhaps dynamically using some script), then I would like that behavior (ie., the beeping sound) to be automatically generated for each link in that page, rather than me having to go in and edit every link manually.

Any way I could use some kind of javascript within a CSS file ? Something like:

a.hover { color=red; Call_function=beep() }

Thanks.

Tags:
Tony
Tony's picture
User offline. Last seen 7 hours 47 min ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2003-03-12
Posts: 3705
Points: 1115

Changing mouseover behaviour for all links using CSS

Hi ga_acad,
You could use javascript to get all the links and add the onmouseover event to each link in window.onload.

   
window.onload= function(){ 
    var alla=document.getElementsByTagName("A");   
   for (i=0; i<alla.length; i++) { 
       /* assign the function to the a */ 
      alla[i].onmouseover=beep(); 
   } 
}
That should be close.

Your question may have already been answered, search and read before you ask.