【发布时间】:2021-12-08 23:46:23
【问题描述】:
我只需关注tutorial就成功创建了一个简单的基于网络的聊天应用程序
唯一的区别是我没有包括登录的东西。它只会在 log.html 中不断发布消息。
现在我正在尝试在 HTA 中执行此操作。这是我第一次使用它。我还在学习,目前正在学习:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta charset="utf-8" />
<title>Chat-App</title>
<meta name="description" content="Chat-App" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<link rel="stylesheet" type="text/css" href="font-awesome-animation.min.css"/>
<link rel="stylesheet" href="styles.css" />
<HTA:APPLICATION
SCROLL="auto"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"/>
<script language="VBScript">
Sub window_OnLoad
Window.ResizeTo 680,723
iTimerID = window.setInterval("Display", 1000)
End Sub
strPath = "C:\Users\username\Desktop\Chat App\"
Set wshShell = CreateObject( "WScript.Shell" )
'strSender = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
Sub Display
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(StrPath & "log.html", 1)
strCharacters = objFile.ReadAll
objFile.Close
chatbox.innerHTML = strCharacters
chatbox.ScrollTop = chatbox.ScrollHeight
End Sub
</script>
</head>
<body style="background-color:grey;">
<div id="wrapper">
<h1 style="margin-top: 5px;margin-left:20px;color:orange;">Chat-App</h1>
<div id="chatbox" name="chatbox" class="textbox">
</div>
<form name="message" action="">
<textarea rows="10" cols="30" name="usermsg" type="text" id="usermsg" style="height:200px;" placeholder="Type your message here..."></textarea>
<input name="submitmsg" type="submit" id="submitmsg" value="Send" />
</form>
</div>
</body>
</html>
这是输出 ..ChatApp
这只会获取 log.html 的内容,然后显示在聊天框 div 中。但它有一个错误,说“显示”未定义。而且 textarea 看起来甚至不像 textarea。
除此之外,我不知道如何在 log.html 中实现发布消息并像教程中那样每隔几秒刷新一次。我尝试粘贴基于 Web 的 javascript,但是当我将其转换为 hta 时它不起作用。有人可以帮我在 HTA 中做吗?
【问题讨论】: