简体   繁体   English

Android浏览器仍然使用旧的Java事件创建方法

[英]Android browser still uses the old way of creating events in Javascript

According to this mozilla.org API guide on triggering events , createEvent and initEvent methods are deprecated event objects Event or CustomEvent show be created in this fashion. 根据该对触发事件mozilla.org API指南 ,createEventinitEvent方法已过时事件对象的事件自定义事件显示以这种方式来创建。

    var ev_name = 'test';
//  var ev = new Event(ev_name);
    var ev = document.createEvent("Event");
    ev.initEvent(ev_name, true, true);

However, this new method doesn't work on Android browser. 但是,此新方法不适用于Android浏览器。 Are these two methods (createEvent and initEvent) really deprecated? 这两个方法(createEvent和initEvent)是否已被弃用?

This is true- The CustomEvent objects do not work in Android native browser. 是的,CustomEvent对象在Android本机浏览器中不起作用。 A simple way to prove this is to go to this website on the android browser: http://blogs.sitepointstatic.com/examples/tech/custom-events/index.html 一种简单的证明方法是在android浏览器上访问该网站: http : //blogs.sitepointstatic.com/examples/tech/custom-events/index.html

Test in Chrome (on Android) and it will work perfectly, as it is just the native Android browser that has issues. 在Chrome上进行测试(在Android上),它将完美运行,因为它只是存在问题的本机Android浏览器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM