Working across frames in webbrowser control
Hello
I have a project to sort work schedules for bidding. The way it works is: I crunch scheds into a DB and give the user an interface with sorting filter options. Then based on their filters it arranges the schedules according to their priorities. When the user is satisfied with the order of their choices they have to transfer their list of choices to a web page for upload.
What I want to do is automate the choice upload process. But, the web page that we use to enter the choices has frames. In the past I used the webbrowser(WB) control to do this, but that was before frames and everything was all in one place and I could just insert the choices and hit the send button from the WB control all with code.
Then along came the new and improved page with frames. And now I'm lost and afraid. :)
But seriously the data entry cells are in one frame and the send button is in another. So I can load up the individual frames in their own WB controls but I can't get it to send.
I used to use this code:
Code:
For Each el In brwWebBrowser.Document.All
If el.Type = "text" Then
'Debug.Print el.Name & " - " & el.Type
bs = el.Name
End If
Next
b = Right(bs, (Len(bs) - 9))
BELineCount = Right(bs, (Len(bs) - 9))
Dim x As Integer
For x = 1 To b
brwWebBrowser.Document.All.Item("BidLineID" & x).Value = Lines(x)
Next
to insert the data with the old page.
Is the WB control capable of doing this sort of operation with frames?
Any suggestions for a solution here?
Thanks
David
Re: Working across frames in webbrowser control
yes you can work with frames, are they standard type frames or iframes
you can work with multiple frames
something along the lines
wb.frames(1).document.all.item........................
wb.frames(2).document.all("Submit").click
for any more i would need to see the page source
Re: Working across frames in webbrowser control
Thanks for the reply
I've never worked with frames before so I'm not sure if this is what you need but I think this is the source from the main frame.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>e-Crew - BidLine</title>
</head>
<frameset rows="125,*" frameborder="no" border="0" framespacing="0">
<frame src="/wtouch/bidline.exe/BIDLINE_NEW" name="top_topFrame" scrolling="No" noresize="noresize" id="top_topFrame" />
<frame src="/wtouch/bidline.exe/4FRAMES" name="main_mainFrame" id="main_mainFrame" />
</frameset>
<noframes><body>
</body>
</noframes></html>
The source of the other frames appears to have jsscript in it for stuff like simo scrolling of frames an such.
Here is the top of the input cells frame:
Code:
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<script src="/wtouch/scrlib.js"><!-- var scr_loaded = false;--></script></head>
<script>
<!--
var MyGap=0;
var NoSortedLinesFound=false;
function vScroll() // begin function
{
var top = document.body.scrollTop;
var left = document.body.scrollLeft;
The code for this frame is about 6 pages long so let me know if there is more you need.
David
Re: Working across frames in webbrowser control
i am not good enough to get the information required from that, ideally i would prefer a link to the site, or the main parts of the frame document login form and submit button areas
as the frames are named you should be able to work with them as elements
vb Code:
set fra1 = wb.document.frames("top_topframe")
with fra1.document.forms(1)
' fill in form
.submit
end with
1 Attachment(s)
Re: Working across frames in webbrowser control
Unfortunately I can't give you a link to the sight for 2 reasons:
1. It's on our company's internal net behind a firewall requiring a user name and PW.
2. And anyway it's not available right now because it's only available for 5 days every 35 days when we bid our schedules.
Here's the entry cell frame source:
Code:
-->
</script><body bgcolor="#cedaf3" onLoad="create_divs()">
<form method="post">
<input type="hidden" name="PriorList" id="PriorList">
<input type="hidden" name="flag" id="flag" value="1">
</form>
<div id="my_rec_prefs" style="display:none">2006,2010,2003,2004,2002,2008,2007,2011,2005,2009,2001,2021,2059,2063,999991</div>
<div id="aLeftDuties" title="68" style="display:none; z-index:-2;">2001,93:26,93:26,302:33,16,2001,CEDAF3,#
2002,95:49,96:37,344:13,16,2002,CEDAF3,#
2003,96:46,98:22,354:30,15,2003,CEDAF3,#
2004,100:54,101:36,371:50,15,2004,CEDAF3,#
2005,95:38,96:41,359:53,16,2005,CEDAF3,#
2006,92:49,92:49,296:53,15,2006,CEDAF3,#
2007,93:20,93:20,366:47,15,2007,CEDAF3,#
2008,92:53,98:29,384:15,15,2008,CEDAF3,#
2009,91:43,95:15,355:22,17,2009,CEDAF3,#
2010,93:07,93:07,313:27,15,2010,CEDAF3,#
2011,94:57,95:51,291:08,16,2011,CEDAF3,#
2012,101:59,102:02,403:56,15,2012,CEDAF3,#
2013,99:54,100:07,387:47,15,2013,CEDAF3,#
</div><div id="tbl_div" style="position:absolute; top:0px; left:0px; width:215px; height:100%%; z-index:0;"><table id="grid" border="1" cellpadding="0" cellspacing="0" style="font-size:10px; font-family:Arial"></table><table id="dummy" border="0" cellpadding="0" cellspacing="0" style="font-size:9px; display:none;"><tr><td> </td></tr><tr><td> </td></tr><tr><td> </td></tr></table></div><div id="rec_action" style="display:none;">/wtouch/BIDLINE.exe</div><div id="cookie_path" style="display:none;">/wtouch</div><div id="cookie_domain" style="display:none;">www.domain.com</div></body>
</html>
I've trunc'd the input cell list part and the jsscript that does stuff like simo scrolling of frames and auto numbering to fit it in a reasonable space.
The lines that end in CEDAF3,# look like they are the input cells. The first and last 4 digit numbers in the row are the id number of the individual schedule packages and the numbers in between are various stats of the schedule. But this is not a type of input object that I recognize. I've attached a snap shot of the page so you can see what it's looks like. you prioritize by putting numbers in the second cell from the left. Them when your done you hit the button at the top.
And to clarify I need to load the whole page, frames and all into the WB control or do I just need the frame that has the input cells?
Thanks
David
Re: Working across frames in webbrowser control
Quote:
And to clarify I need to load the whole page, frames and all into the WB control or do I just need the frame that has the input cells?
if you can manage with only the one page (frame content) then that would simplify your task, but you said something earlier about the submit button being on a different frame, which is confusing as generally the whole form including submit button has to be in a single location (page)
Re: Working across frames in webbrowser control
Yeah that seems weird to me too but when just extract that frame the buttons don't come with it. When I look at the source from the frame above this one I see the submit button is in that frame.
I'll try to see if I can get it to submit from this frame and then try from the main.
Another problem: I don't really see an id for the input cells. Am I missing it or is it something out of my league?
Re: Working across frames in webbrowser control
Quote:
Another problem: I don't really see an id for the input cells. Am I missing it or is it something out of my league?
ids are option, but names are required for forms inputs to post the input
unless the values from the inputs are put into hidden inputs (using javascript or similar) to post, the form you posted above has no visible inputs and no submit, unless it is submitted by javascript
to be able to help in any positive way i would need the full page source of all pages in the frameset, as i realise this is confidential, i probably can do little to help
Re: Working across frames in webbrowser control
Ok I'm looking at the JavaScript from the page and I see several of what look like submit code blocks. But I'm not sure which is which.
I found what looks like the submit buttons html code:
Code:
</div>
<div style="position: absolute; top: 85px; left: 68px; width: 70px; height: 32px; z-index: 0;" class="outter" align="left">
<button type="button" id="_post" onclick="PostPriority()" style="background-color: navy; font-size: 9px; cursor: pointer; width: 70px; font-weight: bolder; color: white;">Record<br>your Bids</button>
</div>
And the JS function that it refers to:
Code:
function PostPriority()
{
if (document.all.awarded_line.innerHTML == "") top.main_mainFrame.leftFrame.PostPriority();
}
But I'm still confused. I'm currently learning a little JS so I can hope fully figure out how this thing works.
Re: Working across frames in webbrowser control
meaningless to me, but i don't believe it is connect to posting the form
the form is the important part to post information, you have a small form in the html you posted in #5, but there must be other forms
all inputs and a submit should be within a form, just need to find which
it would look as if you have frames within your frames
Re: Working across frames in webbrowser control
Ok I've found the input cells and now what I need to figure out is how to get my app to input the numbers in to the fields.
Code:
</div><div id="tbl_div" style="position: absolute; top: 0px; left: 0px; width: 215px; z-index: 0;"><table id="grid" style="font-size: 10px; font-family: Arial;" border="1" cellpadding="0" cellspacing="0"><tbody><tr style="height: 29px;"><td style="width: 29px;">2001</td><td style="width: 30px;" align="center">
<input maxlength="3" id="2001" _prior="" name="spr" size="1" onmousedown="InsertPrior(this)" onkeydown="KeyIsDown(event,this)" style="font-size: 10px; color: maroon; width: 23px; height: 27px;" type="text"></td><td style="width: 40px;" align="center">97:13</td><td style="width: 40px;" align="center">97:13</td><td style="width: 35px;" align="center">382:46</td><td style="width: 31px;" align="center">15</td></tr><tr style="height: 29px;"><td style="width: 29px;">
2002</td><td style="width: 30px;" align="center"><input maxlength="3" id="2002" _prior="" name="spr" size="1" onmousedown="InsertPrior(this)" onkeydown="KeyIsDown(event,this)" style="font-size: 10px; color: maroon; width: 23px; height: 27px;" type="text"></td><td style="width: 40px;" align="center">94:56</td><td style="width: 40px;" align="center">96:09</td><td style="width: 35px;" align="center">344:45</td><td style="width: 31px;" align="center">17</td></tr><tr style="height: 29px;"><td style="width: 29px;">
2003</td><td style="width: 30px;" align="center"><input maxlength="3" id="2003" _prior="" name="spr" size="1" onmousedown="InsertPrior(this)" onkeydown="KeyIsDown(event,this)" style="font-size: 10px; color: maroon; width: 23px; height: 27px;" type="text"></td><td style="width: 40px;" align="center">93:57</td><td style="width: 40px;" align="center">95:10</td><td style="width: 35px;" align="center">323:32</td><td style="width: 31px;" align="center">16</td></tr><tr style="height: 29px;"><td style="width: 29px;">
2004</td><td style="width: 30px;" align="center"><input maxlength="3" id="2004" _prior="" name="spr" size="1" onmousedown="InsertPrior(this)" onkeydown="KeyIsDown(event,this)" style="font-size: 10px; color: maroon; width: 23px; height: 27px;" type="text"></td><td style="width: 40px;" align="center">95:35</td><td style="width: 40px;" align="center">97:06</td><td style="width: 35px;" align="center">327:10</td><td style="width: 31px;" align="center">16</td></tr><tr style="height: 29px;"><td style="width: 29px;">
2005</td><td style="width: 30px;" align="center">
In the past the code that I used was:
Code:
For x = 1 To b
brwWebBrowser.Document.All.Item("BidLineID" & x).Value = Lines(x)
Next
b equals the number of cells that I was inputting. This kept it from running off the end and crashing.
The array lines(x) contains the line choices in their order.
The result of "BidLineID" & x, was the name of the input cell. This won't work with the new page as all of the cells are named "spr". They do however have unique id's which conveniently are the scheduleline numbers.
With the old page the cells were blank and you inserted the id number of your schedule preferences. In the new page cells are numbered and you are prioritizing them by inserting numbers 1, 2 , 3,....
I tried the following code with no luck:
Code:
For x = 1 To b
brwWebBrowser.Document.All.Item(Lines(x)).Value = x
Next
Re: Working across frames in webbrowser control
in the above html all the inputs have the same name (spr)
i guess in the old form the input names were bidlineid1, bidlineid2 ...................
you would have to use something like
vb Code:
brwWebBrowser.Document.getelementbyid("2002").Value = x
how you can incorporate that into your loop, i am not sure, the first one you show is 2001, so you could try like
vb Code:
for x = 1 to 5
brwWebBrowser.Document.getelementbyid("200" & x).Value = x
Re: Working across frames in webbrowser control
Quote:
Originally Posted by
westconn1
in the above html all the inputs have the same name (spr)
i guess in the old form the input names were bidlineid1, bidlineid2 ...................
you would have to use something like
vb Code:
brwWebBrowser.Document.getelementbyid("2002").Value = x
how you can incorporate that into your loop, i am not sure, the first one you show is 2001, so you could try like
vb Code:
for x = 1 to 5
brwWebBrowser.Document.getelementbyid("200" & x).Value = x
Ok I think I'm at an impass here till the real web page is available again.
I tried this code:
Code:
brwWebBrowser.Document.getElementById(Lines(x)).Value = x
The lines array is populated with the id's in the the proper order. So first I ran it with the frame with the input cells loaded. When that failed I thought it might be an issue with the parent frame or something so I tried to load the full window but the webbrowser won't load the full page from my saved copy (I saved it as a full page).
I can load any of the individual frames but not the whole page. I'm guessing that it has something to do with the java script and it's interactions with the server, so I think I'm done for about 4 weeks till the real page is up again.
Thanks for all your help
Re: Working across frames in webbrowser control
Quote:
I'm guessing that it has something to do with the java script and it's interactions
more likely the paths to the pages
anyway if you can't fill the boxes, when loaded in a single page, you won't get it to fill, when in a frame, email me the page source for the single page if you want
Re: Working across frames in webbrowser control
Dave
Just wanted to mention I lurking here. Web stuff is
Greek to me, so maybe I'll learn along with you.
Great image in Post #5, btw. :thumb:
Spoo
Re: Working across frames in webbrowser control
Ok some other projects and stuff dragged me away from this project for a while. That stuff is sorted out now and this project has my full attention once again.
So... where were we?
Ah yes
Tried doing the input on the full page, no luck. Trying to pull just the frame with the input cells out alone but not having any luck getting the frame alone in the webbrowser control.
Any ideas?