|
Hello-
Seems like a simple problem but I can't seem to crack it. I'm building a Browser Helper Object that accesses the elements on a web page using the IHTMLElementCollection it gets from the main document. I can navigate the static elements, get and set their properties, etc. EXCEPT that some of the elements on the page are dynamically generated by JScript at page load time and put into a <div> called 'content'.
How do I access the generated elements? When I access 'content' there is nothing inside, i.e. I can only access elements that are static. You'd think something like content.form.xyz would do it but there's nothing in there.
Any help would be greatly appreciated!! Thanks and best regards,
Nicholas
|
|
|
|
|
Hi there,
Are you sure that the dynamically generated elements are added to their containers already before you run the code to access the containers to get the children as an instance of the IHTMLElementCollection type?
|
|
|
|
|
Thanks for your response... that made me check again and that was the problem!! I thought waiting for READYSTATE_COMPLETE would be enough, but I set it up to enumerate the page elements after an externally-fired event and voila! the items are there.
Now the question is... how do I know when the script that creates those items has finished? Or better yet, how do I know when all the scripts on the page have finished running?
Thanks again!
Nicholas
|
|
|
|
|
Nicholas,
AFAIK, there's no event defined in mshtml can tell you when all the scripts on the web page have finished running or a new item has just been generated and added to its container. So IMHO, you need to provide your own way to handle this thing:
+ If there is an external event which notifies about the new item creation or the completion of the script execution, then you can register an event handler for this event. However, it all depends on the source site which is navigated in the browser.
+ You might want to spawn a child thread which is responsible for periodically checking the children property of the container to see if there's any new item which has been added or detecting a specific condition to see if the script has finished running.
Just some ideas.
|
|
|
|
|
Hmm, ok... you've confirmed what I've been thinking... I'll have to set up a way to monitor things and look for new children.
Thanks for your help!
Nicholas
|
|
|
|
|
is there any comparing of (free) web page systems?
(wps = something can make page in fuctionality say similar to codeproject - see next)
any recommendations, experiences, opinions?
thanks
i'm looking for something like this:
probably gpl, php and mysql solution
support for article database (title, subtitle, text, author, modif date, ...), article categories (maybe multiply selection)
comments for articles, general message boards, mail notifications
author accounts, user acounts, admin accounts (name, password, hidden email, public short profile text), anonymous viewing
the best keep all in one system (= if possible do not combine just publishing system with just messageboard one)
non-english language users (f.e. will want to make search with or without non-english characters (á should be equal to a))
http://www.php-nuke.org/[^]
http://www.mamboserver.com[^]
http://www.phpbb.com/[^]
|
|
|
|
|
Dear Group,
I am struggling to get the size of my dialog editor (the client). I am using the following:
CRect rect;
GetClientRect(&rect);
int width = rect.Width();
int height = rect.Height();
the result i am getting is a huge number, for example: height = 4267921
Please tell me if what i am doing is correct,
Regards
Adam
|
|
|
|
|
I have an if statement that checks to see if a cookie is set.
If the cookie holds a value I would like to automatically follow a link in an iframe. Is there a way to load the link without clicking on it if the if statement is true?
|
|
|
|
|
Hi there,
To simulate a click action on the link, you first need to get reference to the link element, then you simply call the click() method which causes the onclick of the element to get fired.
|
|
|
|
|
I'm having some trouble getting an asp.net intranet project working on a Windows 2003 server -- I got it working on one server, but I want to run it on different one (both are identical, or at least we thought they were) and for some reason (authentication?) it won't work on the second one.
We have a simple html home page that has links to an asp.net app.
After setting up ISS on the first machine, getting it up and accessible from other machines was a snap. On the second machine, the home page wouldn’t even come up. Instead we’d get a "Service Unavailable" page. We got around that by giving the Network Service permissions to registry keys it wanted to get to. Then we could access the html home page (http://machine2/), but accessing the web service (eg. http://machine/AppName/AppName.aspx) stuff doesn’t work. To get this part working on machine1, all I needed to do was change the "Application Settings" to the virtual directory, allowing "scripts only" execute permissions.
We have compared iis configurations on both machines and can’t find the problem. They seem to be identical, but obviously something must be different (maybe elsewhere in the OS config?). When we use the wfetch tool to access the aspx page we get a 401.1 error. We have looked at the permissions between the machines and can't find any difference. Any help here would be greatly appreciated.
Any ideas or pointers to previously answered similar questions, FAQs, etc. appreciated.
Matt Gerrans
|
|
|
|
|
Hi Matt,
There are a number of reasons that can cause the error Http 503 Service Unavailable , you may need to first check the error log file HTTP.sys which should appear in the folder systemroot\System32\LogFiles\HTTPERR . The error Http 401.1 is basically thrown when there's a problem related to the authentication issue. The IIS failed to collect the valid user account or the account supplied by the client side is invalid. May I suggest you to download the IIS Resource Kit[^] which can help you figure out the root cause. The chapters 24, 5, 11 may help.
Also, you might also want to check out the IIS support site[^].
|
|
|
|
|
Thanks for the help.
Turned out after trying a lot of configuration tweaking (system and IIS) to no avail, that uninstalling ISS, removing the whole project, then reinstalling ISS and putting all it back got things working. Apparently there was something strange in the original setup of ISS.
Matt Gerrans
|
|
|
|
|
ASP.NET's validators are great controls, but I have one beef with them: they do not focus (javascript) on the control that they are validating if the entry is invalid. Does anyone know of a CodeProject Control that does this?
The Yellow Dart
|
|
|
|
|
Hi
I m developing intranet application .I wann to know how to view or open the PDF file which is located in some server in the network and whose link has to dynamically produced with the dropdown list selected values . do i need to use any FSO ? i will get PDf file name from database but actually PDF file is located in server in the network.
Hope its not confusing..............
Please help me ........... its very urgent
I will be thankful to u
|
|
|
|
|
If the PDF file is located on the server, just generate a link to it. Or, if you want to do it a little cleaner, you can read the pdf into a byte stream, then stuff that into your page after setting the header to saw it's a PDF.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
:-DHi,
Just Generate the Link Correctly from Database. Before that configure your Acrobat Reader to Display the PDF Files in Web Browser. To Configure this go to Edit -> Preferences -> Internet in Acrobat Reader. o Windows Machines. The PDF can be viewable in browser only when the Acrobat Reader or any pdf viewer software is installed on Client machine otherwise browser will ask for the Download the file.
Tell me your respose......
Sandeep
|
|
|
|
|
Hi, folks.
I'm want my web app to display a list of items (retrieved from a database) in a select box. In my main page I have the following:
<br />
<td bgcolor="#66ccff">Product Messages for: <!--#include file="products_list.inc"--></td><br />
The included file is your typical code fragment that retrieves the data and dynamically builds the selector:
<br />
<%<br />
<br />
set objConn = Server.CreateObject("ADODB.Connection")<br />
objConn.ConnectionString ="driver={SQL Server};server=xidc-mrtline;database=motd;uid=sa;pwd=lmitfd; " <br />
objConn.Open<br />
<br />
strSql = "Select idnum, name from products;" <br />
<br />
set objRS= Server.CreateObject("ADODB.Recordset")<br />
objRS.Open strSQL ,objConn<br />
<br />
Response.Write "<select id=products_list name=products_list onchange='DisplayProductMOTD(this.options[this.selectedIndex].value, DateBox.value)'>"<br />
do while not objrs.EOF <br />
Response.Write "<option value=" & objrs("idnum") & ">" & objrs("name") & "</option>"<br />
<br />
objrs.MoveNext ' Movenext<br />
loop<br />
Response.Write "</select>"<br />
<br />
<br />
objRS.close<br />
set objRS =nothing<br />
<br />
objConn.close<br />
set objConn = nothing<br />
%><br />
Ok, so far, so good. When I change the selection, it calls the 'DisplayProductMOTD function and all is right with the world. Now it has occurred to me that I could use this same list in another context, but I want to call a different function for the onchange event. I've removed the explicit setting of the event from the include file and put it in an init function I have in my main page, products_list.onchange='DisplayProductMOTD(products_list.options[products_list.selectedIndex].value, DateBox.value)'; but I can't get it work.
What am I missing?
Thanks in advance for any help
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Dear group,
I am trying to get the distance between an object and the topmost portion of the content currently visible in the window. I need this to find out if an object (image, paragraph ect) is visible on the screen or not.
I am using the IHTMLElement2 API to do that !!!
IHTMLElement2 *pElement;
...
long scrollTop;
pElement->get_scrollTop(&scrollTop);
The problem is that i get scrollTop = 0 always !!!
Can anyone help, please this is very important
Adam
|
|
|
|
|
Thats the solution for my problem, just in case someone encounters the same problem in the future,
IDispatch *pDisp = m_webBrowser.get_Document();
ASSERT( pDisp ); //if NULL, we failed
// get document interface
IHTMLDocument2 *pDocument = NULL;
HRESULT hr;
hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDocument );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pDocument );
// get the body element from document...
IHTMLElement *pBody = NULL;
hr = pDocument->get_body( &pBody );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pBody );
// get element2 interface,
IHTMLElement2 *pElement = NULL;
hr = pBody->QueryInterface(IID_IHTMLElement2,(void**)&pElement);
ASSERT(SUCCEEDED(hr));
ASSERT( pElement );
long scroll_top;
HRESULT hrScroll = pElement->get_scrollTop(&scroll_top);
Enjoy
Adam
|
|
|
|
|
Why wold y ou like to have .-ts and spaces in your name... varibale names seldom are...
/M
|
|
|
|
|
I would like to be able to grab the images from a web page and put them in a windows.bitmap object. The two main ways I have been able to do this have limitations that don't let them work in my application.
The images are downsampled copies of originals stored in a database. I can use axWebBrowser control to download and show the web page and extract the image address using an mshtml document object but the javascript on the page deletes the downsampled image as soon as it is loaded.
a WebRequest object could be used to download the html and then parse the html to get the address of the image but it won't run the javascrip to delete the copy from the server.
I have thought about a combination of downloading the html to a stream using webrequest, extracting the image url and copying the image to disk, substituting the new image file name into the html stream (so I don't have to download it twice) and then loading the new html into the axWebBrowser to run the script and finally loading the image from disk into a bitmap object.
There has to be a way though to read the bitmap data from the HTMLDocument or similar object directly though. I know the browser keeps it in memory as a bitmap so how do I access it? I have been playing around with the IHTMLDocument2 interface but haven't been able to figure out a way.
There has to be something simple that I am missing here. Any help woud be appreciated.
|
|
|
|
|
This blog[^] presented a way to generate an image of a web page with the use of the IHTMLElementRender interface, and we can customize the sample code to grab the image element on the web form. Instead of using the body element:
IHTMLElement element = (IHTMLElement) document.body; you can get the img element in the document, then you can draw the contents of the image:
IHTMLImgElement element = (IHTMLImgElement) document.images.item("image1", "");
|
|
|
|
|
I'm using a vb6 application to access a web page (hosted by a totally different company) that is seen in the webbrowser control on my form. I can get the value of a combobox, but I'm trying to see how to get the actual text of the item that is displayed. For instance, the combobox may have "minnesota" showing, but the value is 23. I want to know how I can get "Minnesota". I figured I could probably use the elements collection of the combobox and loop through to see if one is selected, but that seems pretty crappy. Anyoneone know how I can get this displayed text instead of the numeric value associated with the selected item?
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Hi there,
I'm not sure if you can do the equivalent in VB 6.
HTMLDocument doc = (HTMLDocument)axWebBrowser1.Document;
HTMLSelectElementClass select = (HTMLSelectElementClass)doc.getElementById("DropDownList1");
IHTMLElementCollection options = (IHTMLElementCollection)select.children;
HTMLOptionElementClass option = (HTMLOptionElementClass)options.item(select.selectedIndex, "");
string text = option.text;
|
|
|
|
|
I've never done javascript before but I need to be able to detect which browser the user is running. I've searched the net and copied some code to do this. It's simple and I understand what it does but I can't get the .html page to display different text per browser. This is what I have in my html:
<br />
<script language="JavaScript" type="text/JavaScript"><br />
<!--<br />
if(BrowserDetect()!="Internet Explorer")<br />
{<br />
document.write('Other');<br />
}<br />
else<br />
{<br />
document.write('Internet Explorer');<br />
}<br />
</script><br />
and this is the code that I found on the internet:
<br />
function BrowserDetect() {<br />
var detect = navigator.userAgent.toLowerCase();<br />
var OS,browser,version,total,thestring;<br />
<br />
if (checkIt('konqueror'))<br />
{<br />
browser = "Konqueror";<br />
OS = "Linux";<br />
}<br />
else if (checkIt('safari')) browser = "Safari"<br />
else if (checkIt('omniweb')) browser = "OmniWeb"<br />
else if (checkIt('opera')) browser = "Opera"<br />
else if (checkIt('webtv')) browser = "WebTV";<br />
else if (checkIt('icab')) browser = "iCab"<br />
else if (checkIt('msie')) browser = "Internet Explorer"<br />
else if (!checkIt('compatible'))<br />
{<br />
browser = "Compatible"<br />
version = detect.charAt(8);<br />
}<br />
else browser = "An unknown browser";<br />
<br />
if (!version) version = detect.charAt(place + thestring.length);<br />
<br />
if (!OS)<br />
{<br />
if (checkIt('linux')) OS = "Linux";<br />
else if (checkIt('x11')) OS = "Unix";<br />
else if (checkIt('mac')) OS = "Mac"<br />
else if (checkIt('win')) OS = "Windows"<br />
else OS = "an unknown operating system";<br />
}<br />
<br />
document.rs_browser=browser;<br />
document.rs_OS=OS;<br />
document.rs_version=version;<br />
<br />
return browser;<br />
}<br />
<br />
function checkIt(string) {<br />
place = detect.indexOf(string) + 1;<br />
thestring = string;<br />
return place;<br />
}
When I view my page in either FireFox or IE it doesn't generate any errors but it also doesn't display any sort of text.
Please Help,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|