shray
小狐狸
小狐狸
  • UID23323
  • 注册日期2008-03-21
  • 最后登录2008-03-26
  • 发帖数8
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
阅读:7392回复:2

w3c 下的 onclick在firefox失效的問題

楼主#
更多 发布于:2008-03-21 00:21
各位大大,我的網頁有段代碼如下
<input type="button" class="lightbutton" value="按此開啟/關閉【圖片】上傳" onclick="piclist.style.display=piclist.style.display=='none'?'block':'none'" />  &nbsp;&nbsp;&nbsp;
<table border="0" width="95%" cellspacing="0" cellpadding="0">
<tbody id="piclist" style="display:none">
<tr><td style="border-right: none; border-top: none; border-bottom: none;">
<fieldset style='width:100%'>
        <div style="overflow:auto;height=100%;"> 
          <table border="0" width="100%" cellspacing="0" cellpadding="0">
            
                  <tr> 
                    <td align="left" valign="top" style="border-right: none; border-top: none; border-bottom: none;">
            
                    <input name="up11" type="button" class="lightbutton" id="up11" value="圖片上傳1" onclick="window.open('http://imageshack.us/iframe.php?txtcolor=111111');" />
                       <span style="color: #EC6492">【上傳後可用的連結網址的英文為 Direct link to image】</span> <br />

</td> </tr>
          </table>
        </div></fieldset></td></tr></tbody></table>


在firefox上如果加了w3c的doctype 宣告宣告,就變得無效,請問這段代碼應如何改才可以用得著呢,請各位幫幫忙指教,多謝~[/code]
wushi777
非常火狐
非常火狐
  • UID12365
  • 注册日期2006-04-17
  • 最后登录2011-04-13
  • 发帖数817
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度1点
1楼#
发布于:2008-03-21 00:21
两种方案:
1.
<input type="button" class="lightbutton" value="按此開啟/關閉【圖片】上傳" onclick="var a=document.getElementById('piclist');a.style.display=a.style.display=='none'?'block':'none'" />

2.
<input id='clickMe'  type="button" class="lightbutton" value="按此開啟/關閉【圖片】上傳"/>
 <script>
  var  b = document.getElementById('clickMe'); 
  b.addEventListener("click",
	  function()
	  {
		  var piclist = document.getElementById('piclist');
		  piclist.style.display= (piclist.style.display=='none'?'block':'none'); 
	  },false);
 </script>
shray
小狐狸
小狐狸
  • UID23323
  • 注册日期2008-03-21
  • 最后登录2008-03-26
  • 发帖数8
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
2楼#
发布于:2008-03-21 00:21
多謝大大的幫忙,終於都解決了,非常感激~~
游客

返回顶部