2017-06-10 55 views
1

我在我的程序中使用Gecko瀏覽器。我試圖在此瀏覽器上打開設計模式:如何打開Gecko的設計模式?

webBrowser1.Document.DomDocument.GetType().GetProperty("designMode").SetValue 
(webBrowser1.Document.DomDocument, "On", null); 

但它不起作用。我該怎麼做?

+0

的可能的複製[如何訪問nsIHTMLEditor接口GeckoFX?](https://stackoverflow.com/questions/33467992/how-to-access-nsihtmleditor -interface-in-geckofx) – Bartosz

回答

1

nsIHTMLEditor可能是一個每個瀏覽器實例,而不是全局實例(如由Xpcom.GetService返回的東西)

人們可以通過獲得nsIEditor像這樣(通過提供一個窗口實例)

var editingSession = Xpcom.CreateInstance<nsIEditingSession>("@mozilla.org/editor/editingsession;1"); 
nsIEditor editor = editingSession.GetEditorForWindow((nsIDOMWindow)Window.DomWindow); 
Marshal.ReleaseComObject(editingSession); 

(或者你可以撥打nsIEditor GeckoWebBrowser.Editor屬性。)

您可以到這個nsIEditor轉換爲nsIHtmlEditor(雖然我還沒有嘗試的話)

GeckoWebBrowser browser = .....; 
// Untested code 
nsIHTMLEditor htmlEditor = (nsIHTMLEditor)browser.Editor; 

從@GreenBear

VB代碼
Dim gEditor As nsIHTMLEditor: 
gEditor = Gbrowser.Editor: 
gEditor.DecreaseFontSize() 
+0

真的很感謝你。 – Kaprog