javascript - 无论 Firefox 中的布局区域如何,工具提示都会在同一位置打开

标签 javascript firefox css

我有一个工具提示,鼠标悬停在左上角打开 页面的“鼠标悬停”。 在 IE8 的情况下,这工作正常并在鼠标所在的位置上方打开 放置但在 Firefox 中它无法计算/解释值。

这是工具提示的代码片段

   function DoFlyOver()
{
  if( ToClear != -1 ) window.clearTimeout( ToClear );
  var thisForm = eval("document." + formName);
  if (FlyOverArea == null) FlyOverArea = document.getElementById("FlyOverArea");

    if (FlyOverArea.firstChild!==null)
        FlyOverArea.removeChild(FlyOverArea.firstChild); // remove all existing content
        FlyOverArea.appendChild(document.createTextNode(FoText));

    FoLeft = $displayOptions.getFlyoverLeftOfCursor();
        FoTop = $displayOptions.getFlyoverTopOfCursor();
    FlyOverArea.style.left = Number(thisForm.mousex.value) + Number(thisForm.scrollx.value) - Number(FoLeft);  
    FlyOverArea.style.top = Number(thisForm.mousey.value) + Number(thisForm.scrolly.value) - Number(FoTop);
    var maxX = (window.screen.width * $displayOptions.getFlyoverThreshold())/100;

// If the mouse is at the extreme right corner the max threshold should the tooltip be //placed.
   if(FlyOverArea.style.posLeft > (window.screen.width - maxX)){

    FlyOverArea.style.left = window.screen.width - maxX;
   }
    FlyOverArea.style.display = "";
    ToClear = setTimeout( "ClearFlyOver()", $displayOptions.getFlyoverVisibleTimeWithCursor(), "JAVASCRIPT" );//set timeout
}

    <DIV ID=FlyOverArea CLASS="FO" STYLE="display: none">
     </DIV> 

我怀疑它有 style.topstyle.left 并尝试使用 style.pixelLeft,style.posleft 但没有用

最佳答案

哈,我找到了答案,Mozilla 无法识别数字,但如果你附加 px 它将设置位置。例如

var theLeft=Number(thisForm.mousex.value) + Number(thisForm.scrollx.value) - Number(FoLeft);
FlyOverArea.style.left = theLeft+"px"

问题解决了

关于javascript - 无论 Firefox 中的布局区域如何,工具提示都会在同一位置打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3922626/

相关文章:

javascript - 在 jquery 自动完成控件上按 escape

flash - 为什么 Firefox 会触发两个嵌入式 swf 请求?

html - 如何模仿断字 : break-word; for IE9, IE11 和 Firefox

python-3.x - Selenium webdriver python 元素屏幕截图无法正常工作

javascript - 手机导航栏拉不出来?

javascript - 使用 javascript 更新 z-index 赋值中的左侧无效

javascript - 结果出现时显示顺序

javascript - 限制每行的字符数并换行,同时保留前导空格

javascript - 在输入更改时更改子级内部的父级状态

jquery - 根据固定标题的高度偏移内容上边距