Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS getElementByID no longer works on IE 11

Status
Not open for further replies.

Mandla Sibanda

Programmer
Jul 15, 2019
2
ZA
Hi Team

Kindly assist in the below. The code serves to load a webpage and input values from a spreadsheet. I have been using it for over 3 years with no problem. The issue started when we upgraded to IE 11...objIE.Document AND getElementByID are no longer recognized. Please assist as I am now doing this process manually and takes up much of my time. See below:


Set objIE = CreateObject("InternetExplorer.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
objIE.Visible = True
objIE.FullScreen=True
objIE.Navigate "
If jobname = "BO_VL_Offline" Then
With objIE.Document
.getElementByID("ctl00_MainContent_otGridView_ctl05_ot_Offline_Actual").value = oojobtimex
end with
End If
 

VBScript is only supported in IE 10 and older. You can use it in IE11 but only in compatibility mode.


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Thanks Mark

Im trying to switch to JS to achieve the same result....but now it won't identify "window" because it isn't running in DOM, i run the script from an external JS file. Is there a way...please see below:

var myWindow = window.open("myWindow.document.getElementById("Content_acbsGridView_Offline_Actual_0").value = "00:00";
 
The DOM is probably not fully loaded by the time you are trying to get and set the element. You can use setTimeout to repeatedly attempt the update. Works, but I don't trust it:

Code:
var winHandle;

            function LoadWindow() {
                // open the window
                var winHandle = window.open("[URL unfurl="true"]http://24088appjnb0003:81/Prod/CIB/Batch_Jobs.aspx");[/URL]

                // check to see if the opened window is fully loaded yet and can access the element
                checkLoaded();

                function checkLoaded() {
                    // see it yet?
                    var el = winHandle.document.getElementById("Content_acbsGridView_Offline_Actual_0"); 
                    if (el) {
                        // yes, do whatever
                        el.value= "00:00";
                        clearTimeout(checkLoaded);
                    }
                    else {
                        // assume not loaded yet, try again 
                        setTimeout(checkLoaded); 
                    } 
                }
            };



Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top