1

我有一个li,其他一些元素,比如divsinputs在这个里面li,以及gridview里面的所有东西。

我有一个onmouseover="calcRoute();"li

PROBLEM:我注意到在内部元素上悬停divs并从元素div出来到父元素div会导致calcRoute();再次执行,即再次绑定谷歌地图,这会导致由于地图重新绑定而闪烁。

TRIED:onmouseenteronmouseleave, 但它不会在所有浏览器中都支持

<li onmouseover="calcRoute(8.4572136,76.94017529999996);return false; ">
  <div class="li-inner">


   <input type="image" name="ctl00$ContentPlaceHolder1$FESearchListingControl1$dlPhotoView$ctl01$imgPhotoView" id="ctl00_ContentPlaceHolder1_FESearchListingControl1_dlPhotoView_ctl01_imgPhotoView" src="../UploadedImages/House2469-22-8-2012.jpg" style="height:142px;width:219px;border-width:0px;">
   <div class="title">

   <a id="ctl00_ContentPlaceHolder1_FESearchListingControl1_dlPhotoView_ctl01_lblPropName" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$FESearchListingControl1$dlPhotoView$ctl01$lblPropName','')">Halloween</a>
    <div class="star"></div>
    </div>
    <div class="address">
        <div class="left-location">


        <span id="ctl00_ContentPlaceHolder1_FESearchListingControl1_dlPhotoView_ctl01_lblDistrict">Trivandrum</span>

        </div>
        <div class="right-price"><span class="WebRupee">Rs</span>
            <span id="ctl00_ContentPlaceHolder1_FESearchListingControl1_dlPhotoView_ctl01_lblPrice">500.00</span>
        </div>    
    </div>
  </div>
</li>
4

1 回答 1

1

您可以将 id 附加到 li 元素并将此 id 传递给 calcRoute 函数。

onmouseover="calcRoute(8.4572136,76.94017529999996, this.id);

然后,在这个函数中,你可以为这个 li 元素设置一个标志,它之前被悬停过。

var hoveredItems = {}; // this is a global object

function calcRoute(x,y,id) {
 // put this control on top so that recurring operations will be prevented from being run.
 if(hoveredItems[id]) return;
 else hoveredItems[id] = true; 
 ..
}

也许这有帮助...

于 2012-10-08T08:03:19.953 回答