AIR 里动态修改style的问题

来源:互联网 发布:parsley.js使用 编辑:程序博客网 时间:2024/05/16 14:08

 最近刚接触air,准备写一个小应用。

实现一个浮动层,并跟随鼠标移动, 用来做。

本来是JS代码,在浏览器里调的好好的。
function ShowTipsWnd(HeroInfo)
{
 var tips=document.getElementById("HeroTips")
 clearAllNode(tips);
 tips.style.visibility ='visible'; 
  tips.style.left   =event.clientX;
 tips.style.top   =event.clientY;
  //--------------------------------------
  var image =document.createElement('img');
 image.setAttribute('src',image_url);
 tips.appendChild(image);
  //--------------------------------------
 }
function HideTipsWnd()
{
 document.getElementById("HeroTips").style.visibility='hidden' ;
}
function MoveTipsWnd()
{
 var tips   =document.getElementById("HeroTips")
 tips.style.left  =event.clientX;
 tips.style.top  =event.clientY;
  
}

到了air里就是不随鼠标移动,跟踪代码发现,style.top 和style.left 始终没有生效。

在网上查了半天.看到网友的一句话:top,left,width之类的在Firefox下需要把单位加上...

就试一下,果然OK了。

 tips.style.left   =event.clientX+'px';
 tips.style.top   =event.clientY+'px';