hi everyone...

i have tried creating an auto updater that will reload a certain div just like on facebooks status/wall refresher, when a user moves the mouse it auto refreshes there wall.

so far i have the code below...but the problem is its just executing my function over and over again. ive tried mouseout/over/hover/move but they all just keep reloading the function forever

<script>
var thewallurl = "<?php echo current_url(); ?> #main-wallinfo";
function loadcomms()
{
$('#main-wallinfo').fadeOut('slow').load(thewallurl).fadeIn("slow");
};
</script>

then i call it here

  <div id="main-wallinfo" onmousemove="javascript:loadcomms()">

any help is greatly appreciated
thanks

onmousemove="javascript:loadcomms()

this is causing repeat execution, so remove this.
when u move mouse over div it will execute.
you want to call it once, then just at the end of page write this lines

<script lang='javascript'>
    loadcomms();
</script>

hi, thanks,its now stopped refreshing for infinity...but i need it to execute when ever the mouse goes over the div, is there a way i can integrate some mouse over with the way you suggested calling the function?

thanks

user mouseover() instead of mousemove()

You may want to use the onmouseover and onmouseout events instead of onmousemove for this scenario.

As JorgeM suggested, use onmouseover and onmouseout to call the same function.

but i removed the mouseover/move as you requested. so its no longer there

this may run only once when u brink mouse pointer on the div and not multiple time as it was in case of mousemove

<div id="main-wallinfo" onmouseover="javascript:loadcomms()">

its doing the same thing

if i quickly hover the div it seems to execute 9 times
if i hold it on the div it never ends

just to let u kno its solved...

it appears you cannot call the same div id that your fading out, or maybe its you need to call inside the starting div??

anyway...i added a new div and entered that id into the url var instead of #main-wallinfo i have #wallinfobox

it now works perfect

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.