You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何检测浏览器是否启用弹窗拦截器(Vaadin框架场景)

关于Vaadin中检测浏览器弹窗拦截器的问题
  • 无法检测浏览器是否启用弹窗拦截器,测试过的Vaadin版本包括14.2.0、14.3.0、14.4.0、14.9.6,在Vaadin V24中也未找到相关配置项。
  • 尝试寻找解决方案时,曾得到使用PopupBlockerDetector类的建议,但该类实际并不存在。
  • 已尝试以下两段示例代码:

示例1:打开外部弹窗检测

String popupUrl = "https://www.example.com/popup";
String windowName = "popup";
int width = 800;
int height = 600;
String features = String.format("width=%d,height=%d", width, height);
Window window = UI.getCurrent().getPage().open(popupUrl, windowName, features);

if (window == null || window.closed || !window.isResizable()) {
    // popup was blocked or closed by the user
    Notification.show("Popup is blocked!");
}

示例2:使用Dialog检测

Dialog dialog = new Dialog();
dialog.add(new Span("Test span"));
UI.getCurrent().add(dialog);
Notification.show(MessageFormat.format("Dialog is opened? {0}", dialog.isOpened()));
  • 问题仅出现在Safari、Firefox浏览器中。

内容的提问来源于stack exchange,提问作者Franco Rolando

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 20:12:39