|
-
Apr 18th, 2005, 11:51 PM
#1
WebBrowser Click Button (JavaScript) [Resolved]
Hi Guys,
This on is a little tricky.....
I have an ADSL Moden that I want to be able to control (thru code) the Wireless function (Enable/Disable).
Sounds easy enough, except there is NO elements that I can use!
The HTML (containing JavaScript) dosn't alude to any "Button" Names or ID's.
I first need to select the button to open a new controlbox (not window, as this stays the same URL) to get to the CheckBox that performs the Wireless control. I also cannot manipulate
this checkbox even when I manualy navigate to this spot! - I get Object not set with .... dialog.
I therefore asumed that the Webbrowser, for what ever reason, isn't holding those objects.
In any case, first things first - I need to be able to .Click that first button 
I have exhausted my use/knowledge of DOM etc.
Ideas?
(PS I will upload the HTML latter)
Cheers 'n' Beers,
Bruce.
Last edited by Bruce Fox; Apr 19th, 2005 at 06:55 PM.
-
Apr 18th, 2005, 11:57 PM
#2
Re: WebBrowser Click Button (JavaScript)
-
Apr 19th, 2005, 12:02 AM
#3
Re: WebBrowser Click Button (JavaScript)
Also, this thread contains allot of good web page automation and parsing techniques.
Data From Webpage
Ps, sup Brucy Bruce
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 19th, 2005, 01:19 AM
#4
Re: WebBrowser Click Button (JavaScript)
Thanks David and Rob .
I'm at home now and trying a few things 
Bruce.
-
Apr 19th, 2005, 01:52 AM
#5
Re: WebBrowser Click Button (JavaScript)
Ok, those methods were similar to what I was doing.
(Also, for what it's worth, I had searched all day, and never came across that post!!)
Anhoo,
I still cant get passed the Run-Time Error '91' With Block Variable yada yada...
However, I need to go back one step, and .Click one of those 'java' buttons.
Attached is the HTML page (text view) and associated controlpanel.
The button in question is "Wireless".
As you can see there is no Button objects...
(Please note I have two issues. 1. Clicking a button, and 2. in another controlset (display of buttons/checkboxs), clicking a CheckBox)
I will say at this time that the CheckBox issue is ovevercome by generating errors on that page load????? If a browser error occurs, I can .Click the CheckBox after cycling the error prompts.... (caching?)
Bruce.
Last edited by Bruce Fox; Apr 19th, 2005 at 07:02 PM.
Reason: Attachments Removed
-
Apr 19th, 2005, 07:29 AM
#6
-
Apr 19th, 2005, 04:17 PM
#7
Re: WebBrowser Click Button (JavaScript)
Thanks for the reply Vader 
Ok, I have attached the JS file (as menu.txt(zip)), and the results of the innerHTML after the page had loaded as innerHTML.txt.
Note: I have many times tried to navigate to the wireless.htm directly thru code, but that generates browser errors. I guess there are a few unset variables that are requried - hence the browser errors. Because of this I have tried to submit a .Click to the 'wirless' button.
VB Code:
WebBrowser1.Document.location.href = "../cgi-bin/webcm?getpage=../html/home/home_wizard.htm"
innerHTML Results:
<FRAME name=fPanel marginWidth=0 marginHeight=0 src=""><FRAME name=fInfo src="../cgi-bin/webcm?getpage=../html/home/home_RelaodHref.htm&var:RelaodHref="><NOFRAMES>
<body bgcolor="#008080">
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</NOFRAMES>
(PS I have clipped the tail end of the attached Java Code (menu.txt))
Regards,
Bruce
Last edited by Bruce Fox; Apr 19th, 2005 at 07:05 PM.
-
Apr 19th, 2005, 04:30 PM
#8
Fanatic Member
Re: WebBrowser Click Button (JavaScript)
I don't understand much of the structure of that site... but it looks like the index page is a frameset that contains other pages. You can get to those pages with the document.frames collection.
It would be much easier if I could just navigate to the page on the web; can you post the URL? I get script errors when I try to open mytext.htm with menu.js.
Author for Visual Basic Web Magazine
-
Apr 19th, 2005, 04:33 PM
#9
Re: WebBrowser Click Button (JavaScript)
Unfortunatly I cannot provide the URL, as its internal to my ADSL Modem.
I will try to iterate Frame collection 
Bruce.
-
Apr 19th, 2005, 04:39 PM
#10
Fanatic Member
Re: WebBrowser Click Button (JavaScript)
Okay; this piece of code may help you. It adds all (inline) frames (including nested ones) to a collection colDocuments. You can use items from colDocuments just like any other document object (e.g. you can use colDocuments(0).body.innerHTML). 
VB Code:
Private Sub GetFrames()
'Purpose: searches all frames in the document(s) and adds them to colDocuments
Dim i As Integer, j As Integer
j = 1
Set colDocuments = New Collection
colDocuments.Add WebBrowser1.Document
Do While j < colDocuments.Count + 1
For i = 0 To colDocuments.Item(j).frames.length - 1
colDocuments.Add colDocuments.Item(j).frames.Item(i).Document
Next i
j = j + 1
Loop
End Sub
Author for Visual Basic Web Magazine
-
Apr 19th, 2005, 05:04 PM
#11
Re: WebBrowser Click Button (JavaScript)
Ok, thats what I needed. I now have the TD/TR matrix.
I will try to iterate thru that and on match, perform a .Click (to envoke the "doLink('/html/home/wireless.htm')!
Bruce.
-
Apr 19th, 2005, 06:02 PM
#12
Re: WebBrowser Click Button (JavaScript)
I have beena ble to load the Collection, iterate thru and determine the index/location of the TD containing the 'Wireless' tag.
Now I have that, I cannot work out the syntax to be used on the WebBrowser.Document to perform a .Click on that item?
VB Code:
WebBrowser1.Document.All.Item(3).body.innerHTML.getElementsByName("TD").Item(8).Click

Bruce.
-
Apr 19th, 2005, 06:06 PM
#13
Fanatic Member
Re: WebBrowser Click Button (JavaScript)
The syntax is fine, but you shouldn't use the WebBrowser1.Document object... just call the Click event from the colDocuments collection.
Author for Visual Basic Web Magazine
-
Apr 19th, 2005, 06:29 PM
#14
Re: WebBrowser Click Button (JavaScript)
Vadar, you Guru you!
Thankyou for your persistance.
Solution:
VB Code:
colDocuments(3).getElementsByName("TD").Item(10).Click
All the best with you problem too 
Regards,
Bruce.
-
Apr 19th, 2005, 06:36 PM
#15
Fanatic Member
Re: WebBrowser Click Button (JavaScript)
You're welcome. As for my problem: I've found a satisfying work-around; but it remains strange behavior...
Author for Visual Basic Web Magazine
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
|