MozTW 討論區

各項 Mozilla 相關軟體與技術討論
現在的時間是 2024-03-28, 22:22

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





發表新文章 回覆主題  [ 6 篇文章 ] 
發表人 內容
文章發表於 : 2005-05-03, 10:44 
離線

註冊時間: 2005-05-03, 10:32
文章: 1
代碼:
<script type="text/javascript">
<!--
  function startmenu()
  { menu0.style.display = "none"; }

  function menu0func()
  { if(menu0.style.display == "none")
     { startmenu();
           menu0.style.display = "block"; }
     else
     {  startmenu();  }
  }
//  End -->
</script></HEAD><BODY onLoad="javascript:startmenu()">
<table align="center"><tr><td>
<a href="javaScript:menu0func()">搜尋站</a>
<div id="menu0">
   - <a href='http://tw.yahoo.com/'>雅虎奇摩</a><br>
   - <a href='http://www.yam.com/'>蕃薯藤</a><br>
   - <a href='http://www.google.com/'>GOOGLE</a><br>
</div>
</td></tr></table>

如以上這支程式的效果在Netscape上無法顯現
有無其他寫法可取代,讓IE跟Netscape都可執行?

(Code formatted by ants)


回頂端
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2005-05-03, 12:21 
離線
[網站管理員]
頭像

註冊時間: 2003-07-22, 11:00
文章: 1796
來自: Sydney
the style.display works for Netscape 6+ and Mozilla, Firefox etc.

Try using following syntax:
代碼:
document.getElementById("menu0").style.display == "none";

_________________
Netscape 9 | SillyDog701: Switch guide | Browser Archive | MozInfo701
MacCentre701 | AntBlog701
Don't steal music.


回頂端
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412
 個人資料  
引用回覆  
文章發表於 : 2006-07-27, 15:55 
if you use Netscape, you can use "visibility=visible" to show or "visibility=hidden" to hide.
代碼:
function showFolder()
{
  if(is.ie)
  {
    if(is.mac || is.ie5 || is.ie6)
      this.css.visibility = "visible";
    else
      this.css.display = "block";
  }
  else
    this.css.visibility = (is.ns4 ? "visible" : "visible");
}

function hideFolder()
{
  if(is.ie)
{
    if(is.mac || is.ie5 || is.ie6)
    {
      this.css.visibility = "hidden";
    }
    else
    {
      this.css.display = "none";
    }
  }
  else if(is.ns4)
  {
    this.css.visibility = "hidden";
  }
  else
  {
    this.css.visibility = "hidden";
  }
}


回頂端
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
  
引用回覆  
文章發表於 : 2006-08-26, 13:55 
我在使用 style.display 的語法出了點小問題,

執行 style.display='block' 時會顯示出來,
執行 style.display='none' 時也會正確的隱藏,但是問題來了,

雖然隱藏了但是原本呈現的地方不會縮回去留下了一段空白,
所以在重複執行 style.display='block' 及 style.display='none',
空白就會越拉越大,畫面就越擠越下面了。

這在 IE 執行是正常的,Firefox 卻有以上的問題,
請問我有哪裡沒注意到呢...@@

範例一︰
代碼:
<script language="javascript">
<!--

function _CS_Show_tr( idx )
{
   if (document.getElementById(idx).style.display=='block'){
      document.getElementById(idx).style.display='none';
   }else{
      document.getElementById(idx).style.display='block';
   }
}

//-->
</script>


<table width="100%"  border="0" cellspacing="2" cellpadding="2" class="meatTxt">
  <form name="form1" method="post" action="" onSubmit="return _CS_checkAdd(this);" enctype="multipart/form-data">
    <tr>
      <td valign="top" bgcolor="#EBEBEB">&nbsp;圖示︰</td>
      <td><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="meatTxt">
        <tr>
          <td>&nbsp;<a onClick="_CS_Show_tr( 'dy_tr' )" style="cursor:hand"><img id="iconpic" src="001/001.gif"> 選擇圖示</a></td>
        </tr>
      <tr id="dy_tr" style="display:none">
          <td>
         <hr color="#EBEBEB" size="1">
            <input name="icon_img" type="radio" value="001/001.gif" onClick="_CS_Show_tr( 'dy_tr' );"> <img src="001/001.gif">
            <input name="icon_img" type="radio" value="001/001.gif" onClick="_CS_Show_tr( 'dy_tr' );"> <img src="002/002.gif">
            <input name="icon_img" type="radio" value="001/001.gif" onClick="_CS_Show_tr( 'dy_tr' );"> <img src="003/003.gif">
       </td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td valign="top" bgcolor="#EBEBEB">&nbsp;內容︰</td>
      <td>
     <textarea name="dia_desc" style="width:40em;" rows="20" class="FormTxt"></textarea></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="Submit" type="submit" class="FormTxt" value="確定送出">
          <input name="myAct" type="hidden" id="myAct" value="COMMAND_ADD"></td>
    </tr>
  </form>
</table>



下面這個範例狀況更嚴重,整個 table 欄位跑的亂七八糟@@

範例二︰
代碼:
<script language="javascript">
<!--


function _CS_type( _this )
{   
   document.all('basis_tr').style.display='block';
   
   document.all('com_tr').style.display='none';
   document.all('mem_tr').style.display='none';
   
   document.form1.cal_ord_basis[0].checked = false;
   document.form1.cal_ord_basis[0].disabled = false;
   document.form1.cal_ord_basis[1].checked = false;
   document.form1.cal_ord_basis[1].disabled = false;
   
   if(_this.value == 1){
      document.all('mem_tr').style.display='block';
      
      document.form1.cal_ord_basis[0].checked = true;
      document.form1.cal_ord_basis[1].disabled = true;
   }else if(_this.value == 2){
      document.all('mem_tr').style.display='block';
      
      document.form1.cal_ord_basis[0].checked = true;
      document.form1.cal_ord_basis[1].disabled = true;
   }else if(_this.value == 3){
      
   }else if(_this.value == 4){
      document.all('mem_tr').style.display='block';
      
      document.form1.cal_ord_basis[0].checked = true;
      document.form1.cal_ord_basis[1].disabled = true;
   }else if(_this.value == 5){
      
   }
}

function _CS_basis( _this )
{
   document.all('com_tr').style.display='none';
   document.all('mem_tr').style.display='none';

   if(_this.value == 1){
   //會員
      document.all('mem_tr').style.display='block';
   }else if(_this.value == 2){
   //公司
      document.all('com_tr').style.display='block';
   }
}


//-->
</script>

<table width="100%"  border="0" cellspacing="2" cellpadding="2" class="meatTxt">
<form name="form1" method="post" action="" onSubmit="return _CS_checkAdd(this);" enctype="multipart/form-data">
          <tr>
            <td bgcolor="#EBEBEB" width="80>&nbsp;<font color="#FF0000">*</font> 標題︰</td>
            <td><input name="cal_ord_title" type="text" id="cal_ord_title" style="width:20em;" class="FormTxt" /></td>
          </tr>
         
          <tr>
            <td bgcolor="#EBEBEB">&nbsp;<font color="#FF0000">*</font> 類別項目︰</td>
            <td>
         <input name="cal_ord_type" type="radio" value="1" onClick="_CS_type( this );"> 日記
         <input name="cal_ord_type" type="radio" value="2" onClick="_CS_type( this );"> 相簿
         <input name="cal_ord_type" type="radio" value="3" onClick="_CS_type( this );"> 專欄<br>
         <input name="cal_ord_type" type="radio" value="4" onClick="_CS_type( this );"> 討論區
         <input name="cal_ord_type" type="radio" value="5" onClick="_CS_type( this );"> 行事曆<br>         </td>
          </tr>
        <tr id="basis_tr" style="display:none">
          <td bgcolor="#EBEBEB">&nbsp;<font color="#FF0000">*</font> 依據︰</td>
          <td>
         <input name="cal_ord_basis" type="radio" value="1" onClick="_CS_basis( this );"> 會員
         <input name="cal_ord_basis" type="radio" value="2" onClick="_CS_basis( this );"> 公司         </td>
        </tr>
        <tr id="mem_tr" style="display:none">
          <td bgcolor="#EBEBEB">&nbsp;<font color="#FF0000">*</font> 選擇會員︰</td>
          <td><input name="mem_name" type="text" disabled class="FormTxt" id="mem_name" style="width:15em;" readonly="true" /></td>
        </tr>
        <tr id="com_tr" style="display:none">
          <td bgcolor="#EBEBEB">&nbsp;<font color="#FF0000">*</font> 選擇公司︰</td>
          <td><input name="com_name" type="text" disabled class="FormTxt" id="com_name" style="width:15em;" readonly="true" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input name="Submit" type="submit" class="FormTxt" value="確定送出">
         <input name="myAct" type="hidden" id="myAct" value="COMMAND_ADD"></td>
          </tr>
</form>
      </table>




回頂端
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)
  
引用回覆  
 文章主題 :
文章發表於 : 2006-08-26, 15:43 
離線
[MozTW 版主群]
頭像

註冊時間: 2004-11-17, 09:53
文章: 1302
來自: 臺灣桃園
剛好看過這種問題 XD

根據 W3C 標準,display 在 TR 的預設值應該是 table-row
所以只要把 block 改成 table-row 即可 ^^

不過呢,IE並不認識 table-row
所以還是要留著用 block 的給 IE 看‧︿‧

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


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2006-08-26, 20:08 
離線

註冊時間: 2006-08-26, 11:20
文章: 6
感謝..解決了我的問題..提供我修正的結果

代碼:
/****************************************
*
* 判別 style.display 的 "table-row"
* 根據 W3C 標準,display 在 TR 的預設值應該是 table-row
* 不過呢,IE並不認識 table-row
* 所以還是要留著用 block 的給 IE 看‧︿‧
*
****************************************/
function style_display_on() {
   
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
      return "table-row";
   } else if (window.ActiveXObject) { // IE
      return "block";
   }
}

/****************************************
*
* style.display 開關
*
****************************************/
function style_display( idx )
{
   if (document.all(idx).style.display=='none'){
      document.all(idx).style.display=style_display_on();
   }else{
      document.all(idx).style.display='none';
   }
}


回頂端
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)
 個人資料  
引用回覆  
顯示文章 :  排序  
發表新文章 回覆主題  [ 6 篇文章 ] 

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


誰在線上

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


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

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