Event is incompatible with IE and FF. Today I encountered some problems with the transmission. Please refer to some methods online and have some experience:
aClassArray[i].onmouseover = function () { //It is OK to write the code directly in it. You can also pass parameters to pass, but it is not convenient to reuse}; aClassArray[i].onmouseover =linkMouseover//It can be used without passing parameters, but it cannot be used in the future arguments.callee.caller.arguments[0]aClassArray[i].onmouseover =linkMouseover()//Putting brackets is an incorrect usage aClassArray[i].onmouseover = function () { linkMouseover(this) };//This can be passed in, you can alert it, but evt.clientX + There is a problem with "px" and it is empty. . . arguments.callee.caller.arguments[0]//You can use this to solve var src = evt.srcElement || evt.target; //You can also follow src======================================================================================================
Attached exercise code
<!DOCTYPE html><html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.10.4.custom.css" rel="external nofollow" /><script src="js/jquery-1.10.2.js"></script><script src="js/jquery-ui-1.10.4.custom.js"></script><style type="text/css">.aClass, .aClass:visited {font-size: 36px;text-decoration: none;color: #0094ff;}.divTips {font-size: 20px;color: red;border: #f00 1px solid;position: absolute;width: 100px;height: 30px;}</style><script type="text/javascript">function initOnOver() {var titleTips = {"baidu": "Baidu Website Tips","163": "163 Website Tips","google": "google website prompt"}var aTag = document.getElementsByTagName("a");var aClassArray = [];for (var i = 0; i < aTag.length; i++) {if (aTag[i].className == "aClass") {aClassArray[aClassArray.length] = aTag[i];}}for (var i = 0; i < aClassArray.length; i++) {var e;aClassArray[i].onmouseover = function () { linkMouseover() };aClassArray[i].onmouseout = linkMouseout;}}function linkMouseover() {var divTips = document.createElement("div");var evt = window.event || arguments.callee.caller.arguments[0]; // Get the event object divTips.className = "divTips";divTips.style.left = evt.clientX + "px";//+px compatible FFdivTips.style.top = evt.clientY + "px";//+px compatible with FFdivTips.innerHTML = "test";document.getElementById("divA").appendChild(divTips);}function linkMouseout() {var divTag = document.getElementsByTagName("div");for (var i = 0; i < divTag.length; i++) {if (divTag[i].className == "divTips") {document.getElementById("divA").removeChild(divTag[i]);}}}window.onload = initOnOver;</script></head><body><div id="divA"><a href="http://www.baidu.com" rel="external nofollow">Baidu</a><br /><br /><br /><a href="http://www.163.com" rel="external nofollow">NetEase</a><br /><br /><br /><a href="http://www.google.com" rel="external nofollow">Google</a></div></body></html>