WebBrowser SendMessage Key.Return?

oneguy

New member
Joined
Nov 11, 2009
Messages
3
Programming Experience
Beginner
Hello Everyone,

I cannot seem to successfully send the Enter key to a webbrowser control using vb.net. I can succesfully send postmessage Tab key and it tabs through the links and controls, but it does not click on the link when I send Enter key.

Here is why I want to use this technique:
The website I am opening has frames, and due to the cross frame scripting policies microsoft forced into the IE control , I cannot retrieve the links from the IFRAMES on the page. So my alternative thinking is to use Tab keys to get to the link and then press Enter.

Please help me out with this one, I've been breaking my head for a week, researching and researching..

Thanks,
Sergio
 
oneguy said:
The website I am opening has frames, and due to the cross frame scripting policies microsoft forced into the IE control , I cannot retrieve the links from the IFRAMES on the page.
Iframe is just a tag element that sets up the inline frame, I think perhaps you don't know the Html DOM. You can access all frame documents by going up to Window level and use Frames property. The frame document is a regular HtmlDocument that you can interact with by regular methods, such as the Links collection for example. So the HtmlDocument you want is not WebBrowser.Document, it could for example be:
VB.NET:
Dim doc As HtmlDocument = Me.WebBrowser1.Document.Window.Frames(1).Document
'or .Frames("frameName")
 
John,

Thank you a lot for stepping up to help me on this one. I had tried the DOM approach and did try the code:
VB.NET:
Dim doc As HtmlDocument = Me.WebBrowser1.Document.Window.Frames(1).Document
'or .Frames("frameName")

Unfortunately, this gives me the "access denied". From my research I understood that this is due to cross site scripting, so I cannot access any links in the frame. but possibly I am wrong, because if it is not allowed, why would they even provide the frames method anyway.

Here's more information: the frame's domain is different. That means that my webpage is on one domain and the frame i'm viewing is from a different domain. Far as I understand this causes cross frame scripting policy to give me the access denied error (below)


Here is what I do:
1. I navigate the webbrowser to the web page. That has 1 iframe element in it (Sergio in U.S.A. this is just an example to illustrate the error)
2. I wait until it fully finishes to load (giving it extra seconds after complete load).
3. I try to get the outerhtml of the frame document by using the following code:
VB.NET:
Dim strSource As String = WebBrowser1.Document.Window.Frames(0).Document.Body.OuterHtml

but I receive the error "Access Denied" :
accessdenied.jpg


I'm sure the problem lies in the different domain in the frame. maybe i can changing the domain of the document to match the domain of the frame but I'm not sure how.

Notes: In this particular example I could retrieve the URL of the frame and get the document directly from the page. but I'm planning on creating frames which are dynamic to the content of the webpage and i will not be able to separately browse to the URL.
 
Last edited:
Here's more information: the frame's domain is different.
Ok, now I understand what you mean, but I don't know how to resolve that.
 
Back
Top