Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为VBScript中的HTML元素调用自定义事件函数_Html_Dom_Vbscript - Fatal编程技术网

为VBScript中的HTML元素调用自定义事件函数

为VBScript中的HTML元素调用自定义事件函数,html,dom,vbscript,Html,Dom,Vbscript,我只想调用VBscript中自定义元素的函数。下面是我当前的脚本代码。但是它破坏了我的应用程序。(目标浏览器为internet explorer) 你知道为什么上面的代码会崩溃吗?我发现上面的代码只支持IE9。其他版本的IE不支持这一点。需要在htm文件中添加以下标记以支持上述代码 “meta http equiv=“X-UA-Compatible”content=“IE=9” 这解决了我的问题 Function SampleFunction() msgbox"samplemessage

我只想调用VBscript中自定义元素的函数。下面是我当前的脚本代码。但是它破坏了我的应用程序。(目标浏览器为internet explorer)


你知道为什么上面的代码会崩溃吗?我发现上面的代码只支持IE9。其他版本的IE不支持这一点。需要在htm文件中添加以下标记以支持上述代码

“meta http equiv=“X-UA-Compatible”content=“IE=9”

这解决了我的问题

  Function SampleFunction()
  msgbox"samplemessage"
  End Function
  set ResponseFn = getRef("SampleFunction")
  set element = document.getElementById("elem id")
  element.addEventListener "OnResponse, ResponseFn , false
  set cEvent = document.createEvent("CustomEvent")
  cEvent.initCustomEvent "OnResponse", false, false, null
  element.dispatchEvent(cEvent)
  element.removeEventListener "OnResponse\", ResponseFn , false