Note that there are some explanatory texts on larger screens.

plurals
  1. POc# access dom javascript generated form
    text
    copied!<p>am loading a webpage using the webbrowser control, in it there is a form that is generateb by javascript.</p> <p>when i tried to access th elements in c#, they cannot be found.</p> <p>the page renders well in a normal browser, but in my winforms app, the form elements are not rendered, i can only see the javascript that generated the form when dubugging</p> <p>a close solution i found on stack was to cast the <code>webbrowser.document.domdocument</code> to <code>ihtmldocument</code>, but i havent been successful with it,</p> <p>this is what am trying to do</p> <pre><code>Dim doc As HtmlDocument = DirectCast(wbMain.Document.DomDocument, MSH.IHTMLDocument) </code></pre> <p>but i get this warning</p> <blockquote> <p>Runtime errors might occur when converting 'mshtml.IHTMLDocument' to 'System.Windows.Forms.HtmlDocument'.</p> </blockquote> <p>and whe i ignore and run, i got this error</p> <blockquote> <p>Unable to cast COM object of type 'mshtml.HTMLDocumentClass' to class type 'System.Windows.Forms.HtmlDocument'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.</p> </blockquote> <p>EDIT A sample javascript</p> <pre><code>&lt;SCRIPT type=text/javascript&gt; (function(){ function runElemGen() { var ElemGenForm = [{"label":"Email:","name":"ElemGen_email_field","oldName":"","value":"","ElemGen":"text"},{"label":"","name":"ElemGensubscribe","oldName":"","value":"Submit","ElemGen":"submit"}]; ElemGenBuildForm({makeDivs: true, arr:ElemGenForm, place:"ElemGen-email-form-"}); } if (window.addEventListener) { window.addEventListener("load", runElemGen, false); } else { window.attachEvent("onload", runElemGen); } })(); &lt;/SCRIPT&gt; </code></pre> <p>can anyone with a solution help</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload