检测移动浏览器上的拖放支持

时间:2019-01-19 14:34:57

标签: javascript android firefox feature-detection

Caniuse says表示Firefox for Android(v63)不支持拖放。这是可以理解的,因为在单应用程序的移动屏幕上拖放并没有多大意义。但是相应的事件是在几个元素上定义的。

如何检测到此“不受支持”?

我想显示一条消息,例如“单击以选择文件或将其拖到此处”,但是如果拖拽部分毫无意义,则显然省去了它。

private void createNotificationChannel() {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    CharSequence name = getString(R.string.channel_name);
    String description = getString(R.string.channel_description);
    int importance = NotificationManager.IMPORTANCE_DEFAULT;
    NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
    channel.setDescription(description);
    // Register the channel with the system; you can't change the importance
    // or other notification behaviors after this
    NotificationManager notificationManager = getSystemService(NotificationManager.class);
    notificationManager.createNotificationChannel(channel);
}}

alert("alert is supported"); if ("ondrop" in document) alert("document.ondrop is defined"); 可以替换为document<div>元素。结果相同。 Windows和Android上的Firefox 64。我也对Chrome解决方案感兴趣(应该可以在任何地方使用)。

A similar question在9年前被问到,其答案被评论为5年前已经过时。答案不能解决我的问题,也不能以任何方式涵盖Android(我与iOS无关,也无法对其进行测试)。

0 个答案:

没有答案