c# - Prevent WebBrowser Control from automatically adding <A> Tag when contentEditable is set -


i use webbrowser control , have text inside like:

some text https://www.example.com text. 

this code way added text , enabled web browser edit contents:

public partial class form1 : form {     private htmlbody _body;      public form1()     {         initializecomponent();         webbrowser1.navigate("about:blank");     }      private void webbrowser1_documentcompleted(object sender,          webbrowserdocumentcompletedeventargs e)     {         _body = ((htmlbody)((htmldocument)webbrowser1.document.domdocument).body);         _body.contenteditable = true.tostring();         _body.innerhtml = "some text https://www.example.com text";     } } 

if run , changed part of link (for type else instead of 'example.com' , lost focus) automatically adds tag <a> around link. can see in innerhtml property. it's wrong me.

is there way avoid behavior? lot!

you can turn off auto-dettecting url in document. so, in documentcompleted evnet after set new content body, add line of code:

webbrowser1.document.execcommand("autourldetect", false, false); 

also can make content editable without adding reference mshtml.dll. can use:

this.webbrowser1.documenttext = @"<html><body contenteditable=""true""></body></html>"; 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -