PDA

View Full Version : Using multiple onMouseOver Events



schmiford
06-26-2007, 05:49 PM
1) Script Title:Using multiple onMouseOver Events

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex11/javascriptsound.htm

3) Describe problem: On my page I have 2 images that require onMouseOver. One is a link button that changes images, the other is an image that changes to another image and plays a sound upon mouse over. Link button worked fine until I added the second thing. I have them coded as two different scripts in the head section. I'm new to Javascript and am not sure how to make both work together, it seems the one is canceling out the other. I wasn't sure how to post my code, that's why it's not here.

ddadmin
06-26-2007, 07:36 PM
In general, you seperate multiple functions to invoke within a same event handler using a semicolon. For example:


<a href="#" onMouseover="dothis(); dothat()">

susie123
08-13-2007, 02:41 PM
Hi. I have a similar problem that I canīt manage to solve myself even after many inet searches on the subject. The code I have is:

<a href="homepage.htm" target="main"
onMouseOver="home.src='../images/buttons/homebutton_over.gif';
window.status='Return to the Home Page', 8000; return true";
onMouseOut="home.src='../images/buttons/homebutton.gif';
window.status= ' '"; return true>
<img src="../images/buttons/homebutton.gif" border="0" name="home"></a>

The rollover button works fine. Itīs the window.status + time that I need the help with. Within this code is the window.status code where I want the text "Return to Home Page" to last for 8 seconds before timing out of showing on the status bar.

This code is obviously wrong because it doesnīt work! What have I done wrong? Hope somebody can help.

Many thanks from a newbie. :)

jscheuer1
08-13-2007, 03:33 PM
That is not a valid parameter of window.status to begin with, and wouldn't work even if used just by itself. You would need a separate function to give you that sort of capability. For example, have something like so in the head of the page:


<script type="text/javascript">
function status_timer (txt, ti){
window.status=txt;
setTimeout(function(){window.status=''}, ti);
}
</script>

Then you could do something like this:


<a href="#"
onmouseover="home.src='some.gif';status_timer('This is a test',8000);return false;"> . . .

Even so, many modern browsers are set to not allow manipulation of the status bar via javascript.

susie123
08-14-2007, 10:26 AM
Thank you John. I&#180;ll give that a go :)

As a newbie to this, is it possible to explain more about the modern browser issue that you mentioned? Many thanks.

jscheuer1
08-14-2007, 03:34 PM
It's a security feature. The thinking is that if you cannot see what a link does (a default action of the status bar) you may be able to be sent to a phishing site, thinking that it is actually the official site of a bank or other institution with which you might share confidential information.

To prevent this, FF, IE, and Opera - probably others, now have it at least as an option to disable the manipulation of the status bar via javascript.

Another less vital reason for this is that many folks just prefer that their status bar be left alone. Some sites go so far as to place animated marquees in the status, for example. This is very annoying to many people. Being able to turn that off is nice.

Another aspect of this is that most modern browsers also allow the status bar to be turned off completely by the user. In a case like that, your code would do nothing, as there would be nothing to do it to.

So, basically this is just another feature (the ability to configure the status bar and keep it out of the hands of the site designers) designed to allow the user to control their browsing experience.

susie123
08-14-2007, 03:40 PM
Thank you so much John for the explanation. Itīs all a lot clearer now :)