Results 1 to 17 of 17

Thread: [RESOLVED] WebBrowser tag "A" click ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    Resolved [RESOLVED] WebBrowser tag "A" click ?

    Hi all,
    I'm try click web link using for VB 6.0 but this is don't have a name or href..

    I wrote the following HTML code:
    <a onclick="javascript:etc">Text</a>

    WebBrowser1.Document.getElementById("Text").Click (not work)

    How do i do that using VB?
    Thanks in advance, Hasan.

    Sorry server is deleted my replays..


    Thanks for replays but my problem here:
    PHP Code:
    <a onclick="fbjs_sandbox.instances.a28768675863.bootstrap();return fbjs_dom.eventHandler.call([fbjs_dom.get_instance(this,28768675863),function(a28768675863_event) {a28768675863_do_job('12','08b5198e17f1ee375b6db12f8f09af1e2fa50590');},28768675863],new fbjs_event(event));return true;">Görev</a
    Help me please, thanks!
    Hasan

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: WebBrowser tag "A" click ?

    <a onclick="javascript:etc">Text</a>

    WebBrowser1.Document.getElementById("Text").Click

    1) "Text" is not the ID
    2) There is no ID and there is no name
    3) etc has to be the name of a Java function and it must be etc(); with open/closing parens.


    The below code snipit will work for a no-name, no-id hyperlink as long as your hyperlink (<a.......>Text</a>) is correct.

    I do think, however, that your <a..........>Text</a> is incorrect. It should be something more like:

    <a href="www.somesite.com" onclick="javascript:etc()">Text</a>


    Add a reference to Microsoft HTML Object Library to your project
    Code:
      '
      '
     Dim HTML As HTMLDocument
     Dim HyperLink As HTMLAnchorElement
     
     Set HTML = WebBrowser1.Document
     
     For Each HyperLink In HTML.links
       '
       ' Set up some If....End If looking for what you want and when found click on it 
       '
       If HyperLink.innerText = "Text" Then   
         HyperLink.Click
         Exit For
       End If  
     Next
      '
      '
    Last edited by jmsrickland; Feb 14th, 2009 at 12:03 AM.

  3. #3
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: WebBrowser tag "A" click ?

    Once you have included the id of the link like jmsrickland said you can use:

    Code:
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
       WebBrowser1.Document.All("your link").Click
    End Sub
    Below is the whole code!
    Code:
    Private Sub Command1_Click()
     WebBrowser1.Navigate "your site"
    End Sub
    
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
     If URL = "your site" Then
       WebBrowser1.Document.All("username").Value = txtUser.Text
       WebBrowser1.Document.All("password").Value = txtPass.Text
       WebBrowser1.Document.All("login").Click
     End If
    End Sub
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    Re: WebBrowser tag "A" click ?

    Anyone help?

  5. #5
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: WebBrowser tag "A" click ?

    Quote Originally Posted by getElementByID
    Anyone help?
    What are you talking about? You have already been given the answer to your problem. See posts #2 and #3

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    Re: WebBrowser tag "A" click ?

    Thanks for help but not working posts #2 and #3

  7. #7
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: WebBrowser tag "A" click ?

    Sure they work. You were told that your hyperlink has to be correct. I tested with your hyperlink (after I made it correct) and it worked just fine.

    Now if you want help you need to reply with a better response than not working. That doesn't tell me anything. Did you add the reference I told you and did you correct your hyperlink? Give me something to go on. Your hyperlink as you have it posted is NOT clickable,
    Last edited by jmsrickland; Feb 14th, 2009 at 11:34 AM.

  8. #8

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    Re: WebBrowser tag "A" click ?

    My "Görev" link not show and not click this code:

    Private Sub Command1_Click()
    Dim HTML As HTMLDocument
    Dim HyperLink As HTMLAnchorElement

    On Error Resume Next
    Set HTML = WebBrowser1.Document
    For Each HyperLink In HTML.links
    txtcode.Text = txtcode.Text & HyperLink.innerText & vbCrLf
    Next
    End Sub

    Thank again, Hasan

  9. #9
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: WebBrowser tag "A" click ?

    Thats because your "G&#246;rev" is NOT clickable. I already told you that. It is NOT a hyperlink until you make it a hyperlink like I told you in post #2

    Here is what you have
    Code:
    <a onclick="fbjs_sandbox.instances.a28768675863.bootstrap();return fbjs_dom.eventHandler.call([fbjs_dom.get_instance(this,28768675863),function(a28768675863_event) {a28768675863_do_job('12','08b5198e17f1ee375b6db12f8f09af1e2fa50590');},28768675863],new fbjs_event(event));return true;">G&#246;rev</a>
    Above is NOT a valid hyperlink and it is NOT clickable. You need to make it a hyperlink by adding some link reference to it like this
    Code:
    <a href="some.link.reference" onclick="fbjs_sandbox.instances.a28768675863.bootstrap();return fbjs_dom.eventHandler.call([fbjs_dom.get_instance(this,28768675863),function(a28768675863_event) {a28768675863_do_job('12','08b5198e17f1ee375b6db12f8f09af1e2fa50590');},28768675863],new fbjs_event(event));return true;">G&#246;rev</a>
    NOTE

    Before you start testing your stuff in VB with a WebBrowser control try testing it with IE and see what you will get. If it wont work in IE then it wont work in WebBrowser.
    Last edited by jmsrickland; Feb 14th, 2009 at 12:19 PM.

  10. #10

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    Re: WebBrowser tag "A" click ?

    Okay, i'm using iMacros (Firefox addon) and it worked just fine.
    TAG POS=1 TYPE=A ATTR=TXT:G&#246;rev (iMacros code)
    Other method click for link ? Javascript function name or etc ..
    Thank you.
    Hasan

  11. #11
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: WebBrowser tag "A" click ?

    Well that still doesn't tell me anything. I have absolutely no idea what you are doing in your VB code and I have no idea what you are navigating to using your WebBrowser control but I believe that it isn't going to work because you are saying it is an addon for FireFox and FireFox is not IE and WebBrowser is IE. Now, does it work using IE or not. If it does not work using IE then it isn't going to work using WebBrowser. What else can I say

  12. #12
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: WebBrowser tag "A" click ?

    @ GetElementByID

    Please upload the whole source code of the page you are talking about! Maybe then we can get the result you are getting and figure out how best to fix it.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  13. #13

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    Re: WebBrowser tag "A" click ?

    Hi again,
    i'm upload files copy this site:
    http://www.jeomustafa.com/mytest.htm
    Thanks, Hasan

  14. #14
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: WebBrowser tag "A" click ?

    Code:
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
       '
       '
     Dim HTML As HTMLDocument
     Dim HTMLI As HTMLInputElement
         
     Set HTML = WebBrowser1.Document
    
     For Each HTMLI In HTML.getElementsByTagName("A")
       If HTMLI.innerHTML = "Gorev" Then
         HTMLI.Click
         Exit Sub  
       End If
     Next
       '
       '
    End Sub

  15. #15

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    Re: WebBrowser tag "A" click ?

    Dear jmsrickland and Nightwalker83 ;
    It's okey.... Very very Thanks!

  16. #16
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: WebBrowser tag "A" click ?

    Quote Originally Posted by getElementByID
    Dear jmsrickland and Nightwalker83 ;
    It's okey.... Very very Thanks!
    Did you manage you solve the problem? If so please mark the thread as "Resolved" and post the solution to the problem in the thread so other people may find it.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  17. #17

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    14

    Re: WebBrowser tag "A" click ?

    Okey thanks.. I give u repp!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width