I am writing BHO for now, which dynamically changes the document.
I faced that thing, that if I do next (after the 'documentcomplete' event in browser)
Code:
//Code:
CComQIPtr<IHTMLElement> piSpanElement;
hr = pHtmlDocument->createElement(L"span", &piSpanElement);
BSTR innerHtml = L" [u]This is string with leading space"</u>";
//leading space is happily ignored, when I'm inserting that text:
hr = piSpanElement->put_innerHTML(innerHtml);
//Ok-ok, I beleive, it is with the good intentions
//of MSHTML, I will try to insert some text...
//I even do not put a whitespace there...
//Ok, I will try to insert some text...
//(In MSDN it is said, that InsertAdjancedText inserts plain text.
hr = piSpanElement->insertAdjacentText(L"beforeEnd",L"Some text");
//OK, text is in element, but... I needed before content, ok, mistake - I try to correct:
hr = piSpanElement->insertAdjacentText(L"afterBegin",L"!I WANNA SEE THIS TEXT IN ELEMENT before content!");
//It does return S_OK... I do not see that text, WTH!?
//I insert this element simply querying interface and
//substituting the DOM node. After that html element tortures.
May be I'm "stupido", but I cannot convert IHTMLDomNode element to the IHTMLElement. If there is any method - please tell..
then - one more...
we have "this node", reference node, and node to substitute
Substituting node is IHTMLDomNode pointer, former IHTMLDOMTextNode with text " " or any other - the result was same.
Code:
CComQIPtr<IHTMLDomNode> resultNode;
VARIANT refNode;
refNode.vt = VT_DISPATCH;
refNode.pdispVal = rNode; //reference node pointer
hr = thisNode->get_parentNode(&pNode); //parent node pointer
//OK, pNode is not null.
hr = pNode->InsertBefore(substitutingNode,refNode,&newNode);
//Why hr is EINVALIDARG???
or just simply - is there any way to insert that eaten leaded space.
Or what I do incorrectly?