this post is the following of Filling Internet Explorer inputbox
We tried to isolate the problem and it seems that I'm not able (maybe due to a JavaScript in the page? - Please take a look to the other post) to correctly address to the specific InputBox I want. The code which I wrote:
Sub AddInfoFromIntranet()
Dim Ie As SHDocVw.InternetExplorer
Dim Doc As MSHTML.HTMLDocument
Dim Elements As MSHTML.IHTMLElementCollection
Set Ie = New SHDocVw.InternetExplorer
With Ie
.navigate "[HERE GOES MY WEBSITE]"
.Visible = True
Do Until Not .Busy And .readyState = 4
DoEvents
Loop
Set Doc = .document
Set Elements = Doc.getElementsByName("Nachnamevalue")
.Quit
End With
Set Ie = Nothing
End Sub
"Nachnamevalue" is a name of an element contained in the "top_window" frame of the web page:
The picture above is what I get opening my desired address, pressing F12 and clicking with the "select item" item on the desired inputbox. At the very beginning instead the page is just a bunch of javascripts (opening page - F12 and copying the content of DOM explorer)
Now, if I try to see what my "Elements" variable is, I get an object basically empty.
If instead I write:
Set Elements = Doc.getElementsByName("top_window")
something is to be found. Unfortunately I'm working on an INTRANET page, so I cannot provide you the address.
EDIT: FULL javascript
<html><head><script language="JavaScript">
function NewWindow(window_name){
var detail;
detail = open(window_name,"detail","dependent,resizable,screenX=50,screenY=50,width=400,height=400");
detail.focus();
}
function NewWindowScroll(window_name){
var detail;
detail = open(window_name,"detail","dependent,scrollbars,resizable,screenX=50,screenY=50,width=600,height=500");
detail.focus();
}
function NewWindowSize(window_name,w,h){
var detail, windata;
detail = open(window_name,"detail","dependent,scrollbars,resizable,screenX=250,screenY=250,width=" + w + ",height=" + h);
detail.focus();
}
function MiniWindow(window_name){
var detail;
detail = open(window_name,"miniwindow","dependent=no,resizable=yes,screenX=0,screenY=0,width=800,height=20");
detail.focus();
}
last_timer="new"
function DoSearch(){
document.Suchform.submit()
}
function wait_and_search(){
clearTimeout(last_timer)
last_timer = window.setTimeout("DoSearch()", 400);
}
function check_kpeq(this_handle){
equ_string = this_handle.value;
text = equ_string.replace(/[^0-9A-Za-z\-]/g,"");
zahlen = text.split(/[\-\/]/);
if (zahlen.length != 4) {falsches_equ_format(this_handle); return false;}
fill="000";
Zahl_1 = fill + zahlen[0];
Zahl_1 = Zahl_1.slice(Zahl_1.length-3)
Zahl_2 = fill + zahlen[1];
Zahl_2 = Zahl_2.slice(Zahl_2.length-1)
Zahl_3 = fill + zahlen[2];
Zahl_3 = Zahl_3.slice(Zahl_3.length-2)
Zahl_4 = zahlen[3];
this_handle.value = (Zahl_1 + "-" + Zahl_2 + "-" + Zahl_3 + "-" + Zahl_4);
return true;
}
function check_anab(this_handle){
anab_string = this_handle.value;
if (anab_string == "") {return true;}
text = anab_string.replace(/[^0-9\-]/g,"");
zahlen = text.split(/[\-\/]/);
if (zahlen.length != 3) {falsches_anab_format(this_handle); return false;}
fill="000";
Zahl_1 = fill + zahlen[0];
Zahl_1 = Zahl_1.slice(Zahl_1.length-2)
Zahl_2 = fill + zahlen[1];
Zahl_2 = Zahl_2.slice(Zahl_2.length-2)
Zahl_3 = fill + zahlen[2];
Zahl_3 = Zahl_3.slice(Zahl_3.length-3)
this_handle.value = (Zahl_1 + "-" + Zahl_2 + "-" + Zahl_3 );
return true;
}
function falsches_anab_format(this_handle) {
t1 = "Ung?ltiges Format f?r HVT AN/AB: >> " + this_handle.value + " <<\n\n";
t2 = "Nur 3 Zahlen mit '-' als Trennzeichen erlaubt\n\n";
t3 = "Z.B.: '01-08-001'"
alert(t1 + t2 + t3);
this_handle.focus();
}
function falsches_equ_format(this_handle) {
t1 = "Ung?ltiges Format f?r EQU: >> " + this_handle.value + " <<\n\n";
t2 = "Nur 4 Zahlen mit '-' als Trennzeichen erlaubt\n\n";
t3 = "Z.B.: '003-2-60-7'"
alert(t1 + t2 + t3);
this_handle.focus();
}
function check_form(){
if (check_kpeq(document.editanlagedata.KPEQ) == false){return false};
if (check_anab(document.editanlagedata.HVAN) == false){return false};
if (check_anab(document.editanlagedata.HVAB) == false){return false};
return true;
}
</script>
<title>Telefon-Suche</title>
<link title="Telefonsuche - Abteilung" href="[XML FILE REGARDING WEBPAGE].xml" rel="search" type="application/opensearchdescription+xml">
<link title="Telefonsuche - Name" href="[XML FILE REGARDING WEBPAGE].xml" rel="search" type="application/opensearchdescription+xml">
</head>
<!-- frames -->
<frameset rows="90,*" bordercolor="#ffffcc" frameborder="0">
<frame name="top_window" src="index.cfm?fuseaction=StdSearchForm" scrolling="No">
<frame name="bottom_window" src="index.cfm?fuseaction=ShowStartpage" scrolling="Auto">
</frameset><noframes></noframes>