2011-06-24 45 views
0

這是我在stackoverflow上的第一個問題,但我已經在這裏做了很多次旅行來解決其他問題,但是我找不到這個問題的答案:如何在xul文件中創建div contentEditable Firefox擴展?如何在xul文件(Firefox擴展)中創建div contentEditable?

-The以下是我希望我的.xul文件的一部分包含在div CONTENTEDITABLE:

<page id="sbEmptySidebar" title="&emptysidebar.title;" 
    xmlns:html="http://www.w3.org/1999/xhtml"> 
<vbox flex="1"> 
<label id="atest" value="&emptysidebar.title;" /> 
</vbox> 
<html:div contentEditable value="Tryitout" style="width:150px;height:200px"/> 
<html:input type="button" value="Bold" onclick="document.execCommand('bold',false,null);"/> 
</page> 

當我這樣做,我收到以下錯誤在我的分機的側邊欄:

XML Parsing Error: not well-formed<br/> 
Location: chrome://emptysidebar/content/emptysidebar.xul<br/> 
Line Number 41, Column 29:<br/> 
`<html:div contentEditable value="Tryitout"style="width:150px;height:200px"/> 
-------------------------------^` 

我已經發現了一些例子,其中DIV做這樣一來,在哪裏,而不是隻是說CONTENTEDITABLE你說CONTENTEDITABLE =「真」:

<page id="sbEmptySidebar" title="&emptysidebar.title;" 
xmlns:html="http://www.w3.org/1999/xhtml"> 
<vbox flex="1"> 
<label id="atest" value="&emptysidebar.title;" /> 
</vbox> 
<html:div contentEditable="true" value="Tryitout" style="width:150px;height:200px"/> 
<html:input type="button" value="Bold" onclick="document.execCommand('bold',false,null);"/> 
</page> 

當我這樣做時,我沒有收到任何錯誤,但沒有顯示,而是一個空白的150x200像素框。有什麼我失蹤,使一個Firefox擴展xul文件中的contentEditable div可能嗎?

回答

1

您在這裏使用的是XHTML,而不是HTML。它必須遵循XML的規則,XML不支持屬性最小化,請參閱http://www.w3.org/TR/xhtml1/#h-4.5。你應該使用完整的形式:

<html:div contentEditable="contentEditable" ... 

也就是說,如果contentEditable沒有在XUL正常工作我也不會感到驚訝 - HTML嵌入XUL往往是沒有做什麼的預期。使用標籤可能會更好,請在該文檔中加載一個HTML文件(例如about:blank)並設置document.designMode = "on"

+0

好的,非常感謝。我只使用了一個iframe,它效果很好! –

+0

對不起,我忘了。 –

相關問題