|
-
Apr 13th, 2011, 05:24 AM
#1
Thread Starter
Fanatic Member
click <a> link without href in webbrowser, how?
am trying to click an <a> link that dosen't have href
for example
html Code:
<a class="classname">
<div class="classname2"></div>
<span class="span">spantext</span>
</a>
how do i do this, this dosen't work?
vb Code:
webbrowser.Document.All("classname").Click
-
Apr 13th, 2011, 05:46 AM
#2
Re: click <a> link without href in webbrowser, how?
Well <a> denotes an anchor try this.
Edit:
webbrowser.Application.Document.All("classname").Click
Note the part in bold. Also, make sure "webbrowser" is actually the name of your web browser.
Last edited by Nightwalker83; Apr 13th, 2011 at 06:05 AM.
Reason: Adding more!
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
-
Apr 13th, 2011, 07:55 AM
#3
Re: click <a> link without href in webbrowser, how?
classname is the value for the class property of the element, where you are trying to use it you need the value of the name property, which it does not have, you need to loop through the elements to find the correct one based on some property, then click it
try like
vb Code:
for each ele in wb.document.all if ele.innertext = "spantext" then ele.click: exit for next
i did not test this so may need a bit of tweaking
edit:thinking about this, it would be improved
vb Code:
for each ele in wb.document.getelementsbytagname("a")
you may also need to use
vb Code:
if instr(ele.innerhtml, "spantext") > 0 then ele.click
of course if spantext is common to other elements, you may need to find someother property value to select the correct anchor
Last edited by westconn1; Apr 13th, 2011 at 08:29 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 13th, 2011, 11:31 AM
#4
Thread Starter
Fanatic Member
Re: click <a> link without href in webbrowser, how?
@Nightwalker83
I get this error
Code:
91 Object variable or With block variable not set
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|