Html VBScript并使用文件存在检查刷新IFrame

Html VBScript并使用文件存在检查刷新IFrame,html,vbscript,Html,Vbscript,我试图每30秒刷新一次iframe,如果页面不可用,则将其切换到错误页面。我得到一个“调用Sub时不能使用括号”错误,vbscript永远无法工作。我看过几个其他人试图做类似事情的例子,我不知道我做错了什么 <!DOCTYPE html> <html> <head> <title>Census Status</title> </head> <body>

我试图每30秒刷新一次iframe,如果页面不可用,则将其切换到错误页面。我得到一个“调用Sub时不能使用括号”错误,vbscript永远无法工作。我看过几个其他人试图做类似事情的例子,我不知道我做错了什么

<!DOCTYPE html>
    <html>
      <head>
        <title>Census Status</title>
      </head>  
      <body>
        <iframe class="main" id="main" src="G:\CensusAlert\Default.html" width="96%" height="95%"></iframe>    
        <script type="text/vbscript">
        Function refreshGadget
        Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set iFrame = document.getElementById("main")
            If objFSO.FileExists("G:\CensusAlert\Default.html") then
                iFrame.src = "G:\CensusAlert\Default.html"
            Else
                iFrame.src = "C:\Program Files\SAMCAlert\Error.html"
            End If
        End Function
        window.setInterval(refreshGadget, 30000, VBScript)
        </script>
      </body>
    </html>

普查状况
函数刷新小工具
设置objFSO=CreateObject(“Scripting.FileSystemObject”)
Set iFrame=document.getElementById(“main”)
如果存在objFSO.files(“G:\CensusAlert\Default.html”),则
iFrame.src=“G:\CensusAlert\Default.html”
其他的
iFrame.src=“C:\Program Files\SAMCAlert\Error.html”
如果结束
端函数
setInterval(刷新小工具,30000,VBScript)

普查状况
函数刷新小工具
设置objFSO=CreateObject(“Scripting.FileSystemObject”)
Set iFrame=document.getElementById(“main”)
如果存在objFSO.files(“G:\CensusAlert\Default.html”),则
iFrame.src=“G:\CensusAlert\Default.html”
其他的
iFrame.src=“C:\Program Files\SAMCAlert\Error.html”
如果结束
端函数
setInterval(“刷新小工具”,30000,“VBScript”)

修复了它,谢谢Ansgar Wiechers

在删除
window.setInterval的参数列表中的括号之前,先看看Eric Lippert关于这个问题的文章。那篇文章正是我需要的谢谢。它真的修复了吗?因为对我来说,它似乎只有在使用
window.setInterval“refreshGadget”,30000,“VBScript”
时才起作用。是的,我首先尝试了,但完全失败了,但在添加引号后,它接受了命令。你给我的那篇文章没有概述这一点,但它让我走上了正确的道路,我可以解释双引号,
SetInterval
需要一个函数名(或一个语句)作为字符串。就像使用
Execute
Eval
或(更复杂的)
GetRef
一样。我想知道的是,它是否与括号一起工作,因为如果sub前面没有
调用
或赋值,就不能用括号调用sub和函数
<!DOCTYPE html>
    <html>
      <head>
        <title>Census Status</title>
      </head>  
      <body>
        <iframe class="main" id="main" src="G:\CensusAlert\Default.html" width="96%" height="95%"></iframe>    
        <script type="text/vbscript">
        Function refreshGadget
        Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set iFrame = document.getElementById("main")
            If objFSO.FileExists("G:\CensusAlert\Default.html") then
                iFrame.src = "G:\CensusAlert\Default.html"
            Else
                iFrame.src = "C:\Program Files\SAMCAlert\Error.html"
            End If
        End Function
        window.setInterval("refreshGadget", 30000, "VBScript")
        </script>
      </body>
    </html>