1 reply [Last post]
ga_acad
Offline
newbie
Last seen: 16 years 17 weeks ago
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
Offline
Moderator
Brisbane
Last seen: 5 days 6 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

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.