最近我在改一個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部位看起來沒啥錯,請問需要怎麼改才對,謝謝回答