My code is to preview webpages when user move mouse over <a></a>. At the same time, my code has other parts using Prototype periodicalupdater. The following code can work well independently:
// javascript preview program start var ci; var xPos,yPos; Event.observe(window,'load',function(){ var elms = document.getElementsByClassName("toplink"); Event.observe(elms[0],'mouseover',function(ev){gotopreview(ev, 0);}); Event.observe(elms[1],'mouseover',function(ev){gotopreview(ev,1);}); Event.observe(elms[2],'mouseover',function(ev){gotopreview(ev,2);}); Event.observe(elms[3],'mouseover',function(ev){gotopreview(ev,3);}); }); function gotopreview(event,ci){ alert(ci); xPos = Event.pointerX(event); yPos = Event.pointerY(event); var getpostid=document.getElementsByName("targetpid"); var getsid = document.getElementsByName("stdid"); var url = "getOnePost.php"; var pars = "stdid="+getsid[ci].value + "&targetpid=" + getpostid [ci].value; var myajax = new Ajax.Request(url,{ method:'get', parameters: pars, asynchronous: true, onSuccess: function(transport){ $('previewWin').update(transport.responseText); $('previewWin').style.top = parseInt(yPos) + 2 + "px"; $('previewWin').style.left = parseInt(xPos) + 2 + "px"; $('previewWin').style.visibility = "visible"; $('previewWin').onmouseout =function(){ $ ('previewWin').style.visibility = "hidden";} } }); } // javascript preview program end // The above code can work well independently. And my html page is link: <html> <head> </head> <body> <a class="toplink" value="XXX">XXX</a> <a class="toplink" value="XXX">XXX</a> <a class="toplink" value="XXX">XXX</a> <a class="toplink" value="XXX">XXX</a> <div id="previewWin"></div> </body> </html> But when it comes to work with the periodical updater, it seems that periodicalupdater send request first, breaking down the preview code setting new Ajax.Request. And the object is no longer refering to the gotopreview function. The following is my periodical code, obj = new Object(); obj.f1 = eventHandler; window.onload = obj.f1; window.onunload = function(){}; function eventHandler(){ postUpdater(); } function postUpdater() { var myAjax = new Ajax.PeriodicalUpdater( "recentPost", "recentPost.php", { method: 'get', frequency: 50 }); } I use firebug to check the program and found that before I move mouse over the "toplink" anchor, the postUpdater() function will send request to the Sever thus, my preview code is no longer work. I know that there is bind and bindAsListener function to bind the gotopreview function. I tried but it's not work also, could some one help me or tell me how to modify the code to make it work? Is there any way stop the periodicalUpdater when it is loaded? Or if I must to use bind or bindAsListener, how to write it correctly in the above code? Any help would be appreciated! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---