阅读:7766回复:2
w3c 下的 onclick在firefox失效的問題
各位大大,我的網頁有段代碼如下
<input type="button" class="lightbutton" value="按此開啟/關閉【圖片】上傳" onclick="piclist.style.display=piclist.style.display=='none'?'block':'none'" /> <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] |
|
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> |
|
2楼#
发布于:2008-03-21 00:21
多謝大大的幫忙,終於都解決了,非常感激~~
|
|