Hi ive been trying to click a close button within a iframe within a webbrowser control..
my code works in WebBrowser.Document not Reading Outterhtml="x"

Try
       WebBrowser1.Document.GetElementById("bannerClose").InvokeMember("Click")
        Catch ex As Exception

        End Try

and

Dim theElementCollection3 As Windows.Forms.HtmlElementCollection
        theElementCollection3 = WebBrowser1.Document.GetElementsByTagName("img")
        For Each curElement As HtmlElement In theElementCollection3
            If curElement.GetAttribute("alt").Contains("x") Then
                curElement.InvokeMember("click")
            End If



        Next

But does not work in InvokeMember("click") in a iframe..

iframe Code:

<a href="javascript:void(0)" onClick="removeOverlayHTML()">
<img style="position:absolute;top:97px;left:290px;border:0;z-index:101;width:10px;height:10px" src="http://www.castup.tv/images/close_button.png" alt="x"/></a>

PLease!!!! Help!! Thank You...

I'm not 100% but wouldn't you need to invoke the "onClick" member?

If this is your own HTML source you can give the <a> tag an id. in this case "Test" then use the following code.

Dim theElementCollection3 As Windows.Forms.HtmlElement

theElementCollection3 = WebBrowser1.Document.GetElementById("Test")

theElementCollection3.InvokeMember("onClick")

The <a> tag looks like this

<a id="Test" href="javascript:void(0)" onClick="removeOverlayHTML()">
<img style="position:absolute;top:97px;left:290px;border:0;z-index:101;width:10px;height:10px" src="http://www.castup.tv/images/close_button.png" alt="x"/></a>

Thanks for your reply.. "click" and "onClick" work.. but seem to have no effect on iframe button heres an image of exit button im trying to click..

5411c28c9bded4d90d441397f0e35d48

Source URl http://www.v-watch.me/live.php?id=20

Im Trying to click on the x click button to close ad banner.. Please help!!

Thanks for your reply.. HTML Source Is Not Mine..

Ok, this is going to hit every <a> tag in the iframe with invoke onclick, but give it a shot

 Dim theElementCollection3 As Windows.Forms.HtmlElementCollection

 'This line now includes access to the iFrame document.
 theElementCollection3 = WebBrowser1.Document.Window.Frames(0).Document.GetElementsByTagName("a")

 For Each Element As HtmlElement In theElementCollection3
     Element.InvokeMember("onClick")
 Next

if there's more than one frame try changing the Frames(0) to another index. if the index is wrong you will get an error.

I got this to work on a quick demo I made here.

http://software.solvoterra.com/example2.html

example2.html has an iframe whose source is sameURL/example.html

Thanks for your reply.. im working with your solution and i keep getting Acces Denied?..

ca12bd1d25a173cf13927607c296faee

Bugger. That's beyond my knowledge I'm afraid. Maybe you could post that response in web development and ask about security within iFrames. I think the VB side is ok.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.