看板 Web_Design 關於我們 聯絡資訊
以下是一個測試範例: <script> <!-- function trigger() { document.getElementById("test").href = 'http://tw.yahoo.com/'; document.getElementById("test").innerHTML = 'Yahoo!'; if ((document.all)&&(document.getElementById)){ // For IE document.getElementById("test").onclick = 'alert("Changed!"); return false;'; } document.getElementById("test").setAttribute('onclick', 'alert("Changed!"); return false;'); } --> </script> <a id="test" href="http://www.google.com/" onclick="trigger(); return false;">Google</a> 此範例在 Firefox 以及 Opera 下皆能正常運作。 原本超連結是顯示 Google,按一下連結之後,文字變為 Yahoo!, href 以及 onclick 屬性也跟著改變。 但是在 IE6 下就無法正常工作。想請問如果我要改變超連結內 onclick 屬性的值, 應該要怎麼寫,才能在 IE 下正常工作呢? -- ╭─我的網站────────╮ │http://www.chweng.idv.tw/ │ │ 我的相簿、我的部落格 │ ╰─────────────╯ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.162.101.247
ileadu:IE7 可正常運作 02/12 22:34