How to check in JavaScript if XMLHttpRequest object supports W3C Progress Events?(如果 XMLHttpRequest 对象支持 W3C 进度事件,如何检查 JavaScript?)
问题描述
如果 XMLHttpRequest
对象支持 W3C 进展事件?我的意思是如果将 onload
、onprogress
、onabort
、onerror
等属性设置为某些处理函数如上所述,那些函数调用了这些事件.
Is there any way to check within JavaScript if XMLHttpRequest
object supports W3C Progress Events? I mean here if setting onload
, onprogress
, onabort
, onerror
, etc. properties to some handler function would have those function called those events, as described.
附加(额外)问题:有没有办法增加 XMLHttpRequest
(例如使用一些计时器)来支持这些事件?
Additional (bonus) question: is there a way to augment XMLHttpRequest
(e.g. using some timers) to support those events?
旁注:我首先在 XMLHttpRequest
这里
推荐答案
你试过这样吗?
try {
var xhr = new XMLHttpRequest();
if ('onprogress' in xhr) {
// Browser supports W3C Progress Events
} else {
// Browser does not support W3C Progress Events
}
} catch (e) {
// Browser is IE6 or 7
}
我在 Firefox &IE8.Firefox 显示它支持它.IE 表示它不支持 W3C Progress 事件.
I tested this in Firefox & IE8. Firefox shows it supports it. IE says it has no support for W3C Progress events.
这篇关于如果 XMLHttpRequest 对象支持 W3C 进度事件,如何检查 JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如果 XMLHttpRequest 对象支持 W3C 进度事件,如何检查 JavaScript?


基础教程推荐
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01