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
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.
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
Re: click <a> link without href in webbrowser, how?
@Nightwalker83
I get this error
Code:
91 Object variable or With block variable not set