MozTW 討論區

各項 Mozilla 相關軟體與技術討論
現在的時間是 2025-08-23, 05:24

所有顯示的時間為 UTC + 8 小時





發表新文章 回覆主題  [ 4 篇文章 ] 
發表人 內容
 文章主題 : 請教.js的問題
文章發表於 : 2006-11-04, 11:58 
我有一個網站,其中的訊息提示"alt="xxx"在IE中可以正常顯示,如下圖
圖檔

但在firefox下,就沒有了效果,變得很醜,請問如何修改呢
圖檔

以下是有關訊息提示的代碼,請各位大大指教,多謝~
代碼:
document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".PopText { font-family: Verdana,Tahoma; background-color: #F4F4F5; border: 1px #BBBBBB dashed; font-size: 12px; padding-right: 6px; padding-left: 6px; padding-top: 6px; padding-bottom: 6px; visibility: hidden; filter: Alpha(Opacity=0)}");

document.write("</style>");
document.write("<div id='popLayer' style='position:absolute;z-index:1000;filter:revealtrans(duration=.2,transition=10) revealTrans(duration=.2,transition=23) alpha(opacity=80,enabled=100)' class='PopText'></div>");

function showPopupText() {
   var o=event.srcElement;
   MouseX=event.x;
   MouseY=event.y;
   if(o.alt!=null && o.alt!="") { o.pop=o.alt;o.alt="" }
        if(o.title!=null && o.title!=""){ o.pop=o.title;o.title="" }
      if(o.pop) {
         o.pop=o.pop.replace("\n","<br>");
          o.pop=o.pop.replace("\n","<br>");   
               }
   if(o.pop!=sPop) {
      sPop=o.pop;
      if(sPop==null || sPop=="") {
         popLayer.filters[0].apply();
         popLayer.style.visibility="hidden";   
         popLayer.filters[0].play();
         popLayer.style.width=""
      } else {
         sPop=o.pop;
         var rpstr="<font color=black>================</font>"
         sPop=rpstr + "<br>" + sPop;         
         sPop+="<br>" + rpstr;
         if(o.dyclass!=null) popStyle=o.dyclass
         else popStyle="PopText";
             
         popLayer.filters[1].apply();
         popLayer.style.visibility="visible";
         popLayer.filters[1].play();
         showIt();
         if (popLayer.offsetWidth>500)
         {
            popLayer.style.width=500
         }
      }
   }
}

function showIt() {
   popLayer.className=popStyle;
   popLayer.innerHTML=sPop;

   popWidth=popLayer.clientWidth;
   popHeight=popLayer.clientHeight;
   if(event.clientX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
      else popLeftAdjust=0;
   if(event.clientY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
      else popTopAdjust=0;
   popLayer.style.left=event.clientX+12+document.body.scrollLeft+popLeftAdjust;
   popLayer.style.top=event.clientY+12+document.body.scrollTop+popTopAdjust;
}

document.onmouseover=showPopupText;
[/img]


回頂端
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; DigExt)
  
引用回覆  
 文章主題 :
文章發表於 : 2006-11-04, 12:01 
離線

註冊時間: 2006-11-04, 11:38
文章: 9
抱歉,上面發帖人是我,第一次發帖忘了登入


回頂端
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; DigExt)
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2006-11-08, 16:24 
離線

註冊時間: 2004-11-05, 16:36
文章: 251
來自: 我國我家
看"alt="xxx"改成"title="xxx"有沒有用


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1) Gecko/20061010 Firefox/2.0
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2006-11-12, 15:37 
離線
[MozTW 版主群]
頭像

註冊時間: 2004-11-17, 09:53
文章: 1302
來自: 臺灣桃園
程式中直接寫出 popLayer 來控制這個 ID 只適用於 IE
標準的寫法應該是 document.getElementById("popLayer")
至於 event.srcElement 可以參考 這個範例 的原始碼
此外,filter 是 IE 的擴充,所以漸漸浮現的效果將無法在 Firefox 中出現

PS. revealtrans 沒有取代的方法,而 alpha 則可以用 opacity 取代
不過要取代的話還需要使用 setTimeout 來跑,挺麻煩的...

_________________
在靜謐的國度裡,擁抱微風--抱風伴靜


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1) Gecko/20061010 Firefox/2.0
 個人資料  
引用回覆  
顯示文章 :  排序  
發表新文章 回覆主題  [ 4 篇文章 ] 

所有顯示的時間為 UTC + 8 小時


誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 6 位訪客


不能 在這個版面發表主題
不能 在這個版面回覆主題
不能 在這個版面編輯您的文章
不能 在這個版面刪除您的文章
不能 在這個版面上傳附加檔案

搜尋:
前往 :  
Powered by phpBB® Forum Software © phpBB Group
正體中文語系由 竹貓星球 維護製作
© moztw.org, Mozilla Foundation
MozTW,Mozilla 台灣社群