【发布时间】:2021-11-09 23:51:59
【问题描述】:
我目前正在尝试弄清楚如何更新 hta 文件中的 div 元素。 hta 调用运行实际脚本的 vbs 文件。我目前的意图是将hta启动到div中的时间写下来,替换已经存在的文本。最后,这将成为我们管理闯入的公司部门的工具。但现在我什至不知道如何将文本写入 div...
我试图通过 document.getElementByID 和 parent.dokument.getElementByID 获取元素,但它一直告诉我“需要对象”,我在哪里写了“oRefreshed.innerHTML...”
谁能帮帮我?
编辑:作者姓名
文件(请注意,在结束的 html 标记下方 vbs 文件开始)
<html>
<head>
<HTA:APPLICATION
id="oHTA"
APPLICATIONNAME="PausentoolByFF"
BORDER="thin"
ICON=".\data\icon.ico"
MAXIMIZEBUTTON="yes"
SCROLL="auto"
SELECTION="no"
SINGLEINSTANCE="yes"
SYSMENU="yes"
VERSION="0.1.0"
/>
<title>
Pausentool
</title>
<link rel="stylesheet" href=".\data\style.css">
<meta name="author" content="">
<meta name="version" content=oHTA.VERSION>
<script Language="vbscript">
Dim loaded
loaded = True
window.resizeTo 1100,620
</script>
<script language="VBScript" src=".\data\pausentool.vbs"></script>
</head>
<body>
<p>
<table>
<tr>
<div class="content menu" id="admin">
<input type="button" class="button" id="adminButton" accesskey="a" title="Admin-Screen öffnen (Alt + A)" value="Administrieren">
</div>
<div class="content menu" id="getKP">
<input type="button" class="button" id="getKPButton" accesskey="p" title="Pausenkarte ziehen (Alt + P)" value="Pausenkarte">
</div>
<div class="content menu" id="refreshBtn">
<input type="button" class="button" id="refreshButton" accesskey="r" title="Pausentool aktualisieren (Alt + R)" value="Aktualisieren" onClick="window.location.reload()">
</div>
<div class="SLA">
<div class="content">
<span id="SLA1">Anzeige der</span><br>
<span id="SLA2">SLA-DATEN</span>
</div>
</div>
<div class="logo" id="logo">
<img src="./data/logo.png">
</div>
<div class="refreshed">
zuletzt aktualisiert:<br>
<div id="refreshed">noch nie (tbd)</div>
</div>
</td>
</tr>
</table>
</p>
<p>
<table>
<tr>
<th class="content">
<input type="button" class="button" accesskey="1" title="diesen Pausenslot wählen (Alt + 1)" value="11:30 - 12:00">
</th>
<th class="content">
<input type="button" class="button" accesskey="2" title="diesen Pausenslot wählen (Alt + 2)" value="12:10 - 12:40">
</th>
<th class="content">
<input type="button" class="button" accesskey="3" title="diesen Pausenslot wählen (Alt + 3)" value="12:50 - 13:20">
</th>
<th class="content">
<input type="button" class="button" accesskey="4" title="diesen Pausenslot wählen (Alt + 4)" value="13:30 - 14:00">
</th>
<th class="content">
<input type="button" class="button" accesskey="5" title="diesen Pausenslot wählen (Alt + 5)" value="14:10 - 14:40">
</th>
<th class="content">
keine Mittagspause
</th>
</tr>
<tr>
<td class="content">
<table id="1">
</table>
</td>
<td class="content">
<table id="2">
</table>
</td>
<td class="content">
<table id="3">
</table>
</td>
<td class="content">
<table id="4">
</table>
</td>
<td class="content">
<table id="5">
</table>
</td>
<td class="content">
<table id="0">
</table>
</td>
</tr>
</table>
</p>
</body>
</html>
If loaded Then
'do stuff
sHour = Hour(Now())
sMinute = Minute(Now())
sSec = Second(Now())
If Len(sSec) = 1 Then sSec = "0" & sSec
If Len(sMinute) = 1 Then sMinute = "0" & sMinute
If Len(sHour) = 1 Then sHour = "0" & sHour
Dim oRefreshed
Set oRefreshed = parent.document.getElementById("refreshed")
oRefreshed.innerHTML = sHour & ":" & sMinute & ":" & sSec
Else
Dim Msg, Style, Title
Msg = "Dieses Script kann nicht alleine gestartet werden. Bitte nutze stattdessen die Pausentool.hta! Bei Fragen wende dich gerne an den Entwickler." ' Define message
Style = vbOKOnly + vbCritical + vbDefaultButton2 ' Define buttons
Title = "falsche Datei" ' Define title
MsgBox Msg, Style, Title 'show Messagebox
End If```
【问题讨论】: