我有一个很长的VBScript代码,可以在HTA中运行。该脚本包括DOM操作,DLL调用和其他脚本。现在,我遇到了一个问题,因为要花很多时间才能在屏幕上呈现文本,因为有很多脚本会暂停HTML解析。
现在,我计划创建一个简单的延迟,该延迟将阻止代码执行,但不会阻止HTML解析。但是我不知道该怎么做。
更新资料
这是我想要的示例代码(对不起,请不要介意我是HTA vb的新语法)
Sub Window_Onload()
Call Main()
End Sub
Sub Main()
Dim delay
el.innerHtml = "Please"
el2.innerHtml = "Help"
el3.innerHtml = "me"
'more scripts here
'more scripts here
'more scripts here
'more scripts here
el4.innerHtml = "this element is dependent to other scripts"
el5.innerHtml = "this element is dependent to other scripts"
el6.innerHtml = "this element is dependent to other scripts"
delay = 2
Call PauseAndRenderHtml(delay) 'this function will block the code execution
'but not the html parsing
'more scripts here
Do While True
'very long scripts that loops and pause, loops and pause........
Loop
End Sub
Sub PauseAndRenderHtml(timeToBreath)
'Take a breath :)
'breath/pause for timeToBreath seconds
End Sub
我需要功能
PauseAndRenderHtml()
最佳答案
这就是我用的。例如,在For
循环中,我将在每个循环中调用它,它将更新HTML。
'This sleep function produces a near-instant delay for inserting a break in script execution
'mainly for updating HTML in the middle of script execution.
Sub Sleepy
strCmd = "%COMSPEC% /c"
objShell.Run strCmd,0,1
End Sub
关于javascript - 给HTML时间呈现文本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30435550/