Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click Button in Frame

Status
Not open for further replies.

hilbertl3

Technical User
Sep 22, 2004
77
US
All,

I have a webpage that I am accessing using the Webbrowser control that has a frame at the top with about 5 buttons.
In code, I need to "find" the button that is labled "download" and then "click" it. Does anyone know how to go about this?

Thanks,

H
 
Code:
function findAndClick(btnValue)
{
  var btns = top.document.getElementsByTagName("button");
  var inputs = top.document.getElementsByTagName("input");
  for (var i=0; i<btns.length; i++)
  {
    if (btns[i].firstChild == btnValue)
    {
      btns[i].click();
      return;
    }
  }
  for (var i=0; i<inputs.length; i++)
  {
    if (inputs[i].type.toLowerCase() == "button" && inputs[i].value == btnValue)
    {
      inputs[i].click();
      return;
    }
  }
  alert(btnValue+" button not found!");
}
See the Javascript forum (forum216)

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Chessbot, thanks for your reply. I need to do this in VB- sorry for not mentioning that. I will try to extract the general approach you're taking though and let you know how it goes. If you have a similar script in VB, however, please post.

Thanks.
 
Sorry-- don't know enough VB to do it.

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
There is a VBscript forum on tek.tips - forum329

Regards


Jakob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top