| 306 | // 事件支持检测. |
| 307 | // 比如 eventSupported('fullscreenchange', document); |
| 308 | function eventSupported(eventName, elem) { |
| 309 | elem = elem || document.createElement('div'); |
| 310 | var prefix = ['o', 'ms', 'moz', 'webkit', '']; |
| 311 | |
| 312 | var l = prefix.length; |
| 313 | var pEventName; |
| 314 | var isFunction; |
| 315 | var setAttr; |
| 316 | |
| 317 | while(l --) { |
| 318 | pEventName = 'on' + prefix[l] + eventName; |
| 319 | |
| 320 | if (pEventName in elem) { |
| 321 | return pEventName.slice(2); |
| 322 | } else if (typeof elem.setAttribute == 'function') { // setAttribute 是元素节点的方法 |
| 323 | setAttr = false; |
| 324 | if (!elem.hasAttribute(pEventName)) { |
| 325 | setAttr = true; |
| 326 | elem.setAttribute(pEventName, 'return;'); |
| 327 | }; |
| 328 | |
| 329 | isFunction = typeof elem[pEventName] == 'function'; |
| 330 | |
| 331 | if (setAttr) elem.removeAttribute(pEventName); |
| 332 | |
| 333 | if (isFunction) { |
| 334 | return pEventName.slice(2); |
| 335 | }; |
| 336 | }; |
| 337 | }; |
| 338 | |
| 339 | return false; |
| 340 | |
| 341 | }; |
| 342 | |
| 343 | // 在指定对象上保存数据 |
| 344 | var data = (function () { |