Stack Overflow tags - How do they display info on mouse over?

前端 未结 5 1068
小蘑菇
小蘑菇 2021-01-27 05:31

At the event of mouse over each Stack Overflow tag displays an information box beneath itself. As long as the mouse is over the tag or over the info box, it continues to be visi

5条回答
  •  耶瑟儿~
    2021-01-27 05:56

    Without being more specific all I can give you is a general idea of how it works.

    The mouseover will trigger an AJAX request (probably after a short timer countdown in order to keep it firing until the pointer has been over the tag for a short time) which queries the SO database about the tag in question. If returns some kind of response, either a HTML fragment which is injected directly into the DOM, or an XML or JSON encoded data block which is used to populate an element which is injected into the DOM. The mouseout event will remove the element from the DOM. I would imagine the AJAX response is also held in a memory cache by the javascript that manages it so that the same data doesn't get repeatedly requested.

提交回复
热议问题