上面的范例是监控一个有name属性的按钮,对于像图片这样的元素,你可以给它一个Name,或者遍历页面元素获得Img元素,下面是一个遍历页面元素的范例:
怎么用vb script脚本读出网页中radio选的值?
代码:
function IntoIT()
On error resume next
Set MyIT = Window.document
for each oEles in MyIT.all
if typename(oEles)= "HTMLFormElement " then
for each oInput in oEles.all
Select Case oInput.Type
case "radio "
if oInput.checked then
astr=astr+oInput.Value+ "Is selected
"
else
astr=astr+oInput.Value+ "Is not selected
"
end if
case "text "
astr= "
text is "+astr+oInput.Value+ "
"case else
end select
next
end if
next
MyIT.write astr
end function
A1
A2
A3
加入收藏夹
基本上就是通过遍历访问页面中的元素来实现的