Hi
My application is using DesignMode feature on Webbrowser control. I'm getting my application to support IE11.
I have asked one question about dummy Undo unit caused by the SetAttribute when we prepare my form (http://social.msdn.microsoft.com/Forums/en-US/92c96597-4483-4ed8-93cb-b443dfaf331c/setattribute-cause-a-dammy-undo-item-on-webbrowser-control-with-ie11-issue?forum=winforms), this is resolved by using "ms-clearUndoStack" clean the undo stack.
Now I face another strange problem. When the user do some operation to change a control name, we will call SetAttribute("InnerHTML",NewName,0) or use the InnerHTML attribute directly, but the it will not counted into undo action.
private void Form1_Load(object sender, EventArgs e)
{
var input = "<button style=\"\">button</button>";
webBrowser1.DocumentText = "<html><body></body></html>";
IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
doc.designMode = "On";
webBrowser1.DocumentText = "<html><body>" + input + "</body></html>";
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
IHTMLElement btn = doc.body.children[0];
var undoTitle = "Cust Undo Operation";
IMarkupServices markupservice = doc as IMarkupServices;
ushort[] chars = new ushort[undoTitle.Length + 1];
for (int i = 0; i < undoTitle.Length; i++)
{
chars[i] = (ushort)undoTitle[i];
}
markupservice.BeginUndoUnit(ref chars[0]);
//doc.execCommand("ms-beginUndoUnit", false, "Cust Undo Operation");
btn.style.left = 200;
btn.style.top = 200;
markupservice.EndUndoUnit();
//doc.execCommand("ms-endUndoUnit");
var enable = doc.queryCommandEnabled("Undo");
var str = doc.queryCommandText("Undo");
doc.execCommand("Undo");
markupservice.BeginUndoUnit(ref chars[0]);
//doc.execCommand("ms-beginUndoUnit", false, "Cust Undo Operation");
btn.setAttribute("innerHTML", "Button2", 0);
//btn.innerHTML = "Button2";
markupservice.EndUndoUnit();
//doc.execCommand("ms-endUndoUnit");
var enable2 = doc.queryCommandEnabled("Undo");
var str2 = doc.queryCommandText("Undo");
doc.execCommand("Undo");
}The above code demos the problem. It is success to undo the position change but not undo the rename action on IE11. On IE10/9, it works well. You can check the str2 value, it gets Can't Undo in IE11 but it was Cust Undo Operation in IE9/10.
I also try to use newer "ms-beginUndoUnit" and "ms-endUndoUnit" API to replace iMarkupService, but get same result.
Any suggestion on that?
Regards,
Yi
MSC on Computer Science (Parallel algorithm)