问题
There is a html file including alert message. And I want to load the html file at vbs file through internetExplorer. How can I make the alert stay on the top and block other windows using vbscript? But I can’t handle the html file. Can I control the alert in html with vbscript even if internetExplorer’s visible is false in vbscript?
Vbs file ↓
Option Explicit
Dim ie
Dim window
Dim document
Dim url
url = "C:/tmp/screenTest.html"
Set ie = WScript.CreateObject("InternetExplorer.Application")
ie.navigate("about:blank")
Set document = ie.Document
Set window = document.parentWindow
With ie
.Top = (window.screen.availHeight - ie.Height + 50) / 2
.Visible = False
End With
ie.navigate url
Set ie = Nothing
Set window = Nothing
Set document = Nothing
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body onload="alertTest();">
<script>
function alertTest(){
alert("test");
}
</script>
</body>
</html>
来源:https://stackoverflow.com/questions/63386128/create-html-alert-that-stays-on-the-top-and-block-other-windows-with-vbscrips