You are here: Re: mouse-overs in CSS « HTML « IT news, forums, messages
Re: mouse-overs in CSS

Posted by Toby Inkster on 04/29/06 17:40

Mice Over wrote:

> But my main question was this: the statements that use phrases like
> "onmouseover" and "onmouseout" can be used in as style attributes

onmouseover / onmouseout are HTML attributes that fire event handling
code, usually written in Javascript -- they have nothing to do with CSS as
such.

What I think you're trying to ask is: "is there a way of assigning
code to happen in response to events without littering my code with lots
of onmouseover attributes?"

The answer is yes, but it doesn't involve CSS. Here's a quick example:

<script type="text/javascript">
// Utility function -- this is often useful!
function addLoadEvent (func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function')
{
window.onload = func;
}
else
{
window.onload = function()
{
oldonload();
func();
}
}
}

function myfunc1 ()
{
window.alert("Hello");
}

function init_behaviours ()
{
var els = document.getElementsByTagName("TD");
for (var i=0; els[i]; i++)
els[i].onmouseover = myfunc1;
}

addLoadEvent(init_behaviours);
</script>

This will attach the behaviour "myfunc1" to all table cells onmouseover
events.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Now Playing ~ ./b52s_-_love_shack.ogg

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация