Forum Moderators: open

Message Too Old, No Replies

MouseOver event handler

another how-to by a newbie

         

xtian

11:05 pm on Jun 3, 2004 (gmt 0)

10+ Year Member



Is there a way (I guess there is) to trigger a JavaScript ticker (starts running when the page loads by default) from a hotspot or a textlink on the page by MouseOver? I would be grateful for any help.

Thanks
Christian

Bernard Marx

11:36 pm on Jun 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes :)

Can't do much without knowing more, but I imagine your current page has an onload handler in the body tag

<BODY [blue]onload = "someFunction()"[/blue]>
.

If so, to get your mouseover, put

[blue]onmouseover = "someFunction()"[/blue]
into whatever tag it is you like...and have fun.

xtian

8:29 am on Jun 4, 2004 (gmt 0)

10+ Year Member



The script is basically triggered by <script language=JavaScript1.2 src=n_newsbar.js></script> in the body and I am trying to trigger it by mousing over some image on the page instead. I removed the above tag and tried different ways like:

<A HREF="javascript:void(0)" onMouseOver="MM_callJS(n_newsbar.js);">
<IMG SRC="imagefile.gif" NAME="myimage"
WIDTH=75 HEIGHT=40 BORDER=0></A>

but for some reason I cannot get it to work.

Thanks for any help

whoisgregg

2:44 pm on Jun 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perhaps if you define the ticker in your external file as a function, then call that function with the onMouseOver?

In your file "n_newsbar.js" wrap the whole ticker thing into a function like:
function myticker() {
...javascript stuff...
}

In the head:
<script language="JavaScript" src="n_newsbar.js" type="text/javascript"></script>

In the body:
<A HREF="javascript:void(0)" onMouseOver="myticker();">
<IMG SRC="imagefile.gif" NAME="myimage"></A>

Bernard Marx

4:15 pm on Jun 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I haven't messed with Dreamweaver for a long time, but it looks like there is some DW involvement here, and that xtian has momentarily confused the concepts of script and function. MM_callJS presumeably loads the script at that source (but you would also expect the n_newsbar.js to be "quoted".) Really, yes, I'd have thought we'd be calling a function instead.

Link to the script (with quoted attributes - tut, tut).

[blue]<script language="JavaScript1.2" src="n_newsbar.js"></script>[/blue]

Maybe replace language with type="text/javascript"
Then we need to know what function we're calling....
-------------
It seems the script comes from here: [smartmenus.org ]

xtian

4:23 pm on Jun 4, 2004 (gmt 0)

10+ Year Member



thank you very much!

I gave it a try but the trouble is that this seems to cause a reload in the same browser window on mouseover. What is left is an empty window.

xtian

Bernard Marx

4:47 pm on Jun 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



er.. where were we?

If you are getting the script to load onmouseover, then I reckon the script (assuming that it's a Don't worry, we'll handle it all type script) will overwrite your page.

What did you actually do?

xtian

9:09 pm on Jun 4, 2004 (gmt 0)

10+ Year Member



oops, msg.#6 was an answer to #4 really...

alright, what did I do: in the meantime I had tried whoisgregg´s suggestions that produced the empty window mentioned in #6 instead of the Dreamweaver stuff. It looked as follows:

wrapping of the whole script (which is from [smartmenus.org...]
function myticker() {...}

head: <script language="JavaScript" src="n_newsbar.js" type="text/javascript"></script>

body (inside <td>...</td> tags, which shouldn´t be a problem, I suppose): <A HREF="javascript:void(0)" onMouseOver="myticker();"><IMG SRC="images/led_red_shadow.gif" NAME="myimage"></A>

Cheers
Christian