Results 1 to 9 of 9

Thread: Solved [2005] HTML Doc event triggering and AJAX in a client-side app

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    7

    Resolved Solved [2005] HTML Doc event triggering and AJAX in a client-side app

    I need to build a client side application that will load a webpage and automate several tasks, i.e. programmatically trigger the onclick event below and so on.

    I've come up with the following code that works well up until I get to the last batch of elements I need to simulate a click on.

    Here's the code.


    Code:
     ListBox1.Items.Clear()
            Try
                'get number of elements in the document
                Tot = WebBrowserMain.Document.All.Count
                TextBox1.Clear()
                'generate list of clickable elements only
                For I = 0 To Tot - 1
                    CurrentLink = WebBrowserMain.Document.All(I).getattribute("ID").ToString
                    If InStr(CurrentLink, "fgh") > 0 Then
                        ListBox1.Items.Add(CurrentLink.ToString)
                        temp = I
                        'ok so we got an element "I", that contains the right IDs
                        'now trigger the internal event
                        hElement = WebBrowserMain.Document.All(I)
                        hElement.ScrollIntoView(True)
                        hElement.InvokeMember("onclick")
                        Log("Clicked link")
                    End If
                Next
                Log("END")
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
    And here's the html that's relevant, it contains AJAX.

    Code:
    <div id="app2437228683_diggComment3435209" fbcontext="7c279ec28a71">
    	<center>
    
    <a style="cursor: pointer;" onclick="fbjs_sandbox.instances.a2437228683.bootstrap();return fbjs_dom.eventHandler.call([js_dom.get_instance(this,2437228683),function(a2437228683_event) {a2437228683_doajax('Comment3435209', 'http://74.86.142.204/~tearswep/humanpets/diggComments.php?cid=3435209&amp;up=1&amp;diggs=2&amp;poster=556985114&amp;herd=1', '')},2437228683],new js_event(event));return true">
    <img src="http://x.x.x.x/up.jpg" width="30" height="30" /></a><br />
    When run the code works fine for buttons, checkboxes etc, but stalls on this onclick event, and I don't know why. I imagine it's because that although contained within the ID of the element I've captured, the event itself isn't named, or perhaps there's something else preventing it. I'm not a developer, and I only use VB on occasion, so any help is greatly appreciated!
    Last edited by katanshin; Dec 9th, 2007 at 07:30 PM. Reason: Solved

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