Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #12485
| From | "Newyana2" <Newyana2@invalid.nospam> |
|---|---|
| Newsgroups | microsoft.public.scripting.vbscript |
| Subject | IE automation |
| Date | 2023-08-22 22:38 -0400 |
| Organization | To protect and to server |
| Message-ID | <uc3rfe$hgk7$1@paganini.bofh.team> (permalink) |
I've been making a WebBrowser wrapper component to replace
InternetExplorer.Application in scripts, as IE is not available
in Win10. It's just a simple wrapper, made to match IE as
much as possible.
An odd glitch has turned up. I wonder if anyone knows why.
In one test script I create a webpage that has a TEXTAREA
and a button INPUT. The page is loaded and displayed in the
browser window.
When the button is clicked it sets the TITLE of the TEXTAREA
to "OK". There's a script loop that waits for that, then saves
the text and closes the window. In some cases I write the
webpage, save to file, and navigate to it. In other cases I
use document.write to load the webpage. The button has ID
But1. I can use But1_onclick() to set the TITLE or I can
use the button onclick event in that INPUT tag. All variations
of this work on XP. On 7/10, the sub from the button click
never fires when I use document.write to load the page.
It's not a showstopper, as I can write the file to disk and
then navigate to it, and that works. But I'm wondering if
there's something I'm missing. Different security in IE8
and later? Something else that I could work around by
coding it differently.
This is the code of the webpage loaded:
<HTML><HEAD><SCRIPT LANGUAGE="VBScript">
Sub But1_onclick()
T1.title = "OK"
End Sub
</SCRIPT>
<STYLE> BODY {font-family: verdana; font-size: 12px;} TEXTAREA {font-family:
verdana; font-size: 12px; color: #800000;}</STYLE>
<TITLE></TITLE></HEAD>
<BODY>These are the URLs found: <BR><BR>Edit list as desired, then click
Finish.<BR><BR>
<TEXTAREA ID="T1" ROWS=15 COLS=50 WRAP="off"></TEXTAREA><BR><BR>
<INPUT ID="But1" TYPE="button" VALUE="Finish"></INPUT><BR><BR></BODY></HTML>
This is the loop that waits for the button click:
Do While IE.Visible = True
If IE.document.getElementById("T1").title = "OK" Then
s1 = IE.document.getElementById("T1").value
Exit Do
End If
If (IE.visible = False) Then Exit Do
WScript.sleep 500
Loop
It's fine on XP. On 7/10 it never leaves the loop because
the sub is never called.
Back to microsoft.public.scripting.vbscript | Previous | Next | Find similar
IE automation "Newyana2" <Newyana2@invalid.nospam> - 2023-08-22 22:38 -0400
csiph-web