943,892 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 679
  • VB.NET RSS
Jun 17th, 2009
0

How to click a 'show more' label with vb which has a embedded java script

Expand Post »
[code=html]
VB.NET Syntax (Toggle Plain Text)
  1. <A class=F11 id=moreFF4Link style="DISPLAY: inline" onclick="showMoreFF4('on');clickTrackSwbdAttr('BP:Attributes:Additional Info:Show More','Trattoria-Pizzeria-Roma Inc','Pizza Restaurants, Restaurant Management &amp; Consultants')" href="javascript:void(0);"><BR>Show More &gt;</A>

This is the html of that page. I am looking forward to clicking on 'show more'
I am using a instance of Ie to open this page, As this is supposed to back end process I can't use sendkey
Any other way to get around?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lalchetian is offline Offline
10 posts
since May 2009
Jun 19th, 2009
0

Re: How to click a 'show more' label with vb which has a embedded java script

Quote ...
Any other way to get around?
Use web browser control.

Here's your (simplified and modified) HTML
VB.NET Syntax (Toggle Plain Text)
  1. <html>
  2. <script>
  3. function showMoreFF4()
  4. {
  5. alert('foo');
  6. }
  7. </script>
  8. <body>
  9. <A id=moreFF4Link style="DISPLAY: inline" onclick="showMoreFF4()" href="javascript:return(0);"><BR>Show More &gt;</A>
  10. </body>
  11. </html>
And the code to "click" that link
VB.NET Syntax (Toggle Plain Text)
  1. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2. ' Load test page
  3. WebBrowser1.Navigate("http://127.0.0.1/test.html")
  4. End Sub
  5.  
  6. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  7. '
  8. Dim Link As HtmlElement
  9.  
  10. ' Get element
  11. Link = WebBrowser1.Document.GetElementById("moreFF4Link")
  12. ' Found?
  13. If Link IsNot Nothing Then
  14. ' Call method
  15. Link.InvokeMember("onclick")
  16. End If
  17.  
  18. End Sub
If you want to use external browser, you can't access the document itself. You could try to send a mouse click. Google http://www.google.com/search?q=send+mouse+click+vb.net but I doubt a bit you'll find a reliable method to send a mouse click exactly where you want to.

HTH
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Jun 20th, 2009
0

Re: How to click a 'show more' label with vb which has a embedded java script

The query was for vb and not vb.net.

There's some problem with this loop
visual basic Syntax (Toggle Plain Text)
  1. If Link IsNot Nothing Then
  2.  
  3. ' Call method
  4.  
  5. Link.InvokeMember("onclick")
  6.  
  7. End If

it gives an error 424: object required
and yah i can't find htmlelement in vb and hece used htmlanchorelement

Thanks for help
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lalchetian is offline Offline
10 posts
since May 2009
Jun 21st, 2009
0

Re: How to click a 'show more' label with vb which has a embedded java script

Quote ...
The query was for vb and not vb.net.
This is VB.NET forum.

Quote ...
There's some problem with this loop
It's not a loop, it's an If statement

Quote ...
it gives an error 424: object required
It has a test If Link IsNot Nothing Then to ensure that Link variable is an object. So it must be InvokeMember("onclick") part that causes the error. That method doesn't produce an error even if the member (onclick in this case) isn't found. It seems that you've slightly modified the code and run it with VB6, am I right?
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Jun 21st, 2009
0

Re: How to click a 'show more' label with vb which has a embedded java script

for counter=1 to 3
print ("sorry")
next

1) I can't find a vb forum here

2) as you would have already known, am a beginner and was out of my mind then

3) If Link IsNot Nothing Then was giving a error as invalid use of property so removed it,
so you're right the problem is with InvokeMember("onclick")
any solutions.....!!!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lalchetian is offline Offline
10 posts
since May 2009
Jun 21st, 2009
0

Re: How to click a 'show more' label with vb which has a embedded java script

Quote ...
I can't find a vb forum here
Here's DaniWeb's Visual Basic 4 / 5 / 6 forum.

Quote ...
as you would have already known, am a beginner and was out of my mind then
That's ok

Quote ...
any solutions.....!!!!
VB6's web browser control does not have either GetElementById or InvokeMember methods. I can think of only two solutions: try to google (I gave link before) how to send mouse clicks, or the better one, close this thread and re-post this question to DaniWeb's Visual Basic 4 / 5 / 6 forum.

I still have VB6 installed so I took a quick look, but I didn't find any solution with VB6, sorry!
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Checkbox in Datagrid has to click twice to uncheck.
Next Thread in VB.NET Forum Timeline: Playing mp3's





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC