Click here to Skip to main content
16,007,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Al

As a newbie I am struggling with what is probably a simple code change so would appreciate any assistance.

I have a working onmouseover test which calls a function and I want to temporarily suspend this so the function runs all the time (irrespective of whether the mouse is over my field).

HTML
"<div style=' top: "+ yy +"px; left: "+ xx+"px; position: absolute; z-index: 1; visibility: show;'><table><tr><td align=left><img src='"+icon+"' border=0 /><br><b><a href='' onmouseover='javascript:functionname(function parameters;);' >"+name+"</a></b></td></tr></table></div>";


So I thought I could just modify this to -

HTML
"<div style=' top: "+ yy +"px; left: "+ xx+"px; position: absolute; z-index: 1; visibility: show;'><table><tr><td align=left><img src='"+icon+"' border=0 /><br><b><a href=''  javascript:functionname(function parameters;); >"+name+"</a></b></td></tr></table></div>";


And the function would then run irrespective, but it doesn't. What am I doing wrong? Possibly just syntax?

Regards
Active

What I have tried:

Removing the onmouseover check does not call the function.
Posted
Updated 1-Aug-16 10:46am
Comments
F-ES Sitecore 1-Aug-16 11:48am    
What does the function do? You can call it when the page loads by simply putting a script block at the bottom of the page;

<script>yourFunctionName();</script>

That might not be what you want though, it all depends what this function does.
Member 2389900 1-Aug-16 11:53am    
Hello,

The function makes a list appear (the output of a select statement on a database) at certain times (a function within a function). It is not something I would call on a page load. I cannot see why such a basic call fails (or perhaps that is the problem, removing the onmouseover has effectively removed the call).

Regards
Active
F-ES Sitecore 1-Aug-16 12:00pm    
*Something* has to trigger the call to the function. Maybe what you're looking to do is call the function every second or maybe three seconds using window.setInterval?
Member 2389900 1-Aug-16 12:11pm    
Hello again

The 'primamry' function (which contains what was the onmouseover test) is already being called / triggered correctly by a select statement running on a database, returning rows.

The onmouseover= then displayed those rows (normally hidden) when the mouse hovers.

Removing onmouseover= and leaving methodname() should, I thought, call methodname correctly. But apparently not.

Regards
Active
Richard Deeming 1-Aug-16 13:02pm    
As F-ES said, something has to trigger the call to the function.

If you don't want it to run when the page loads, and you don't want it to run when the user hovers over the link, then when do you want it to run?

1 solution

Hello Richard

The code I presented above and reproduced below (with the onmouseover section) is already a subsection of a main function which is called / run automatically by another part of the code.

HTML
"<div style=' top: "+ yy +"px; left: "+ xx+"px; position: absolute; z-index: 1; visibility: show;'><table><tr><td align=left><img src='"+icon+"' border=0 /><br><b><a href='' onmouseover='javascript:myfunctionname(myfunctionparameters);' >"+name+"</a></b></td></tr></table></div>";


I need to change the code so when the main function runs then this subsection calls / runs myfunctionname(myfunctionparameters) without relying on any mouse movement, mouseover etc. My only problem is trying to work out the correct syntax to use.

So instead of onmousever= I need go= or start= or call= or run= or something else?

Regards
Active
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900