hello everybody,
I have script in VBS. when I translate it into JS I can't access
"document.script". generally, that script cooperates with html page,
which contains its own title and:
<script>
var IEvar = 3.14;
showIEvar = function () { return IEvar; }
</script>
the purpose of VBS script is to look after particular Internet Explorer
window that contains this html page. when found, a reference to IE
window is returned and VBS script can execute functions and set
variables hard-coded in this html page.
when I try to code the same in JS I end with the following error message:
oIE.document.parentWindow.document.script is null or not an object
code: 800A138F
I did search google for "document.script" but what I read is still
mysterious to me.. I suppose oIE which points to IE window is set
correctly since I can execute the following statement:
Wscript.Echo(oIE.document.title);
I would appreciate any suggestions and help from both js or vbs
scripters. I enclose these short scripts below.
regards,
mirek
*** original VBS version by Joe Earnest (works great)
set oShell = createObject("shell.application")
set oWins = oShell.windows
on error resume next
for each oWin in oWins
do
qIE= cbool(instr(lcase(typename(oWin.document)), _
"htmldocument"))
if err then exit do
if qIE then
sTitle= trim(oWin.document.title)
if err then exit do
if (lcase(sTitle)="commontitle") then
set oIE= oWin
exit for
end if
end if
loop until true: err.clear
next: set oWin= nothing: set oWins= nothing
on error goto 0
'these statements work
localvar = oIE.document.parentWindow.document.script.IEvar
Wscript.Echo(oIE.document.parentWindow.document.script.showIEvar())
*** JS version without error handling (does not work)
var oShell = WScript.CreateObject("shell.application");
var oWins = oShell.windows();
var oWinsEnum = new Enumerator(oWins);
var oIE;
if(oWinsColl != null) {
for (;!oWinsEnum.atEnd();oWinsEnum.moveNext()) {
var wi = oWinsEnum.item();
if(wi.document.title == "commontitle") oIE = wi;
}
}
//this executes fine
WScript.Echo(oIE.document.title);
//these don't work
WScript.Echo(oIE.document.parentWindow.document.script.showIEvar());
WScript.Echo(oIE.document.parentWindow.document.script.IEvar);