mshtml

How do I use MSHTML on a machine that does not have Visual Studio installed?

I am using mshtml to parse HTML in my ASP.NET-MVC application. Works great on my development machine, which has VS2008 Professional installed. Works great on my staging machine, which has VS Express 2008/WebDev installed. But it throws a FileNotFoundException when trying to load the COM object on the production server, which has no ve...

IHTMLElementCollection sometimes generates a UnauthorizedAccessException

We use the IHTMLElementCollection in an ASP.NET 2.0 application. Sometimes- not always - it gives us a UnauthorizedAccessException. I think it only happens on our server, and not locally. I tried searching in searchdotnet.com, and found only 2 results, but in both of them the use of IHTMLElementCollection was the solution to that except...

Using MSHTML ATL Whats the best way to highlight parts of a web page?

Wanting to highlight stuff in web pages as you mouse over, but there seem to be so many ways you can set display properties I'm having trouble finding a good way to change the display so that it can change back and still keep close to what the user was already looking at. The IE 8 developer tools Outline tool does something like what I ...

How to get the most current IHTMLDocument2 object from IE DOM

Currently, I use MSAA to get an IHTMLDocument2 object from a IE HWND. However, with some complicated web applications, this IHTMLDocument2 object may contain serveral IHTMLDocument2 objects, some of them are not belong to the current displaying page, but the previous page. It seems to me, IE sometimes doesn't refesh its DOM object, but...

mshtml.HTMLDocumentClass in C#

In C#, I managed to get the entire HTMLDocumentClass from an InternetExplorer object (navigating to a certain URL). However, in Visual Studio 2008's debug mode, the content of this HTMLDocumentClass for this particular URL is MASSIVE, including attributes like activeElement, alinkColor, all, applets, charset, childNodes, etc, etc ,etc. ...

Accessing DOM elements in C#

I am using the mshtml namespace to access DOM elements as returned by a COM Browser object. My code is roughly as follows object missing = Type.Missing; ie.Navigate("http://website.com", ref missing, ref missing, ref missing, ref missing); mshtml.HTMLDocument theDoc = (mshtml.HTMLDocument)ie.Document; mshtml.HTMLDivElement myDiv = (msh...

Does the ID's of DOM change from browser to browser?

In C#, I am using the mshtml.HTMLDocument to retrieve various elements from a page. For example: button = (mshtml.HTMLButtonElement)theDoc.getElementById("ID1"); Now, if I am running IE6,IE7,IE8, will "ID1" change depending on browser version? ...

IHTMLTxtRange.pasteHTML doesn't replace old HTML

I'm writing a simple HTML WYSIWYG editor using Microsoft's mshtml. One of the features should be selecting a header type (e.g. h1, h2, h3) for a selected text. The first assignment is no problem with the following code: // *doc* is my IHTMLDocument // *tag* contains the header tag IHTMLTxtRange range = (IHTMLTxtRange)doc.selection.crea...

How to change position of caret in MSHTML during mouse click?

I have a MSHTML-based control embedded in an application and the ContentEditable mode is used to edit documents inside it. The body of the HTML document initially contains the following lines: <div></div> <div id="signature"></div> The caret is placed at the beginning of the document, that is inside the first DIV element. Now when use...

Selecting a textrange from textarea

Hello, I'm trying to set a selection on a textrange from the active TextArea, but it doesn't work. The code below selects the text from the cursorposition, which can be anywhere if the user clicks the textarea, and sets the selection from there to the endposition. var textRange = (IHTMLTxtRange)_activeHtmlDocument2.selection.createRang...

c# webbrowser control displaying "special folder" contents : why are Document and DocumentDom always null ?

Hi, In a C# WinForms, .NET Framework 3.5, project with a WebBrower control on the form : ... with a project reference set to MSHTMLdll and the WinForm code : "using mshtml;" ... you can load a "special folder," like the Favorites folder, into the browser easily. after you've loaded a "special folder" : what appears in the WebBrowser ...

Is it possible to draw a part of a web page using the IHtmlElementRender interface?

I'm currently testing with the HTML below. What i basicly want is to be able to render only the div element with id "test3". <html> <body> <div id="test1" style="background-color:purple;">test1</div> <div id="test2" style="background-color:red;">test2</div> <div id="test3" style="background-color:yellow;">test3</div> </body> </...

URL Moniker Examples for C# (IMoniker)

Dear lazyweb, I am trying to implement an URL Moniker for MSHTML that will be used to provide images from a storage (in the application) to the HTML Edit control. I have understood that to do this I must implement the IMoniker interface. I have not found any decent documentation or sample code anywhere for this. (All MSDN documentatio...

How to get HTML element coordinates using C#?

Hello, I am planning to develop web crawler, which would extract coordinates of html elements from web pages. I have found out that it is possible to get html element coordinates by using "mshtml" assembly. Right now I would like to know if it is possible and how to get only necessary information (html,css) from web page, and then by us...

How do I allow XSS in an embedded IE browser?

I have a windows application with an embedded web control and I want to enable cross site scripting. Is this possible? From what I've read, IInternetSecurityManager.ProcessUrlAction does not allow this. It also sounds like IInternetSecurityManager.GetSecurityId might be able to solve this issue, however I haven't been able to get it to w...

Using IHTMLElementRender Interface in Winodws mobile Pocket Internet Explorer.

Hi All, We would like to use IHTMLElementRender Interface in Windows mobile Pocket Internet Explorer for drawing HTML element content into our custom window DC but found that interface is not not exposed in PIE, Do we have any alternative PIE interface IPIEHTMLElementRender? Regards, Ramanand Bhat. ...

How can I use IHTMLTxtRange.pasteHTML to paste HTML containing a span with a class?

Dim selection As IHTMLTxtRange = Doc.selection.createRange() selection.pasteHTML("<span class=""header"">" + selection.text + "</span>") I am using the above code to wrap the selection in span tags but the pastHTML method is removing the quotes around my class name. Is there another way to do this or am I doing something wrong...

How to parse onclick javascript event parameter using MSHTML?

I need to extract the javascript call in the onlick event defined in the following markup: <div style="cursor: pointer;" onclick='javascript:start("a", "b", "code");'>Click Here</div></div> This is what I want to extract from onclick as a text string: 'javascript:start("a", "b", "code");' I am a novice at using MSHTML and this is wha...

MSHTML MFC Tutorial

Hi, I know this has been asked twice before but both had no proper replies and are dated so in case someone has found something in these days, I'm asking again!. Any one knows any good tutorial for MSHTML or some open source project which can be read to understand how various operations can be done in MSHTML - MFC? Thanks ...

WPF WebBrowser control doesn't enter design mode when the document property is changed

Dear LazyWeb, I have a frustrating problem. Here's a simplified version of what I'm doing: A UserControl in c# contains a toolbar and an embedded WebBrowser object. The toolbar contains an "Edit" button, which when clicked sets the webbrowser control in design mode. Another button, "Cancel", turns off design mode. Pseudocode (very sim...