MozTW 討論區 https://forum.moztw.org/ |
|
有可能是網址特殊符號造成的錯誤嗎 https://forum.moztw.org/viewtopic.php?f=18&t=39021 |
第 1 頁 (共 1 頁) |
發表人: | knives [ 2012-12-07, 15:48 ] |
文章主題 : | 有可能是網址特殊符號造成的錯誤嗎 |
最近我在改一個custombutton 的自訂按鈕 裡面有用到Firefox的XUL 的dom 新增元件的方法 代碼: var checkbox = document.createElementNS(HTML_NS, "input"); checkbox.setAttribute("type","checkbox"); checkbox.setAttribute("id", imgInfo.id+"-CheckBox"); checkbox.setAttribute("rel_id",imgInfo.id); checkbox.setAttribute("value",imgInfo.url); checkbox.setAttribute("label",imgInfo.url); checkbox.setAttribute("class", "chb"); cellBox.appendChild(checkbox); var label= document.createElementNS(HTML_NS, "label"); try{ label.innerHTML = (imgInfo.url); label.setAttribute("for",imgInfo.id+"-CheckBox"); if(true) { label.style.display="block"; label.style.width="200px"; } cellBox.appendChild(label); } catch(e) { alert(e.message+":"+dump(imgInfo,0)); } 現在遇到一個問題 在那個try 裡面的label.innerHTML = (imgInfo.url); 我發現每當imgInfo.url有包含特殊符號都會跳出下面的錯誤訊息 代碼: An invalid or illegal string was specified : 'id' => "t58" 'url' => "http://www.ckarea.com/uc/avatar.php?uid=932140&size=small" specified 後面是我用dump把imgInfo印出來 可是url部位看起來沒啥錯,請問需要怎麼改才對,謝謝回答 |
第 1 頁 (共 1 頁) | 所有顯示的時間為 UTC + 8 小時 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |