【问题标题】:Intercept dialog from <webview> and read the contents从 <webview> 拦截对话框并读取内容
【发布时间】:2015-05-31 14:55:26
【问题描述】:

我使用此代码截取来自 webview 的对话框,但我看不到内容或与之交互:

  Element webview= querySelector("#webview");
  Map<String,String> map=new Map();
  map["src"]=urlWebView+user;
  webview.attributes.addAll(map);
  querySelector("#webview_cont").style.visibility="visible";
  window.addEventListener("dialog",(Event e){ //Use window or webview returns the same result
        e.preventDefault();
        ... //What should I do here ??
    } );

有什么解决办法吗? 谢谢

编辑

调试:

未解决的问题:https://code.google.com/p/dart/issues/detail?id=23556

【问题讨论】:

  • 您阅读过文档吗?我建议你do it again
  • 是的,但该事件不返回有关对话框或文本类型的任何信息。
  • 尝试将监听器附加到 webview 元素,而不是 window
  • 返回完全相同的结果
  • 所以您尝试访问属性并且它们返回未定义?我对 Dart 不熟悉,但是“Event”类型从何而来?

标签: webview dialog dart google-chrome-app


【解决方案1】:

问题肯定出在你对 Dart 的 Event class 的使用上。

它根本不支持 Chrome 添加到事件中的extra propertiese.dialoge.messageTexte.messageType

似乎没有现成的解决方案,at least not in chrome.dart

遗憾的是,我对 Dart 的了解还不够,无法为您提供解决方案。您需要以某种方式扩展该事件类,可能会下降到 JS 级别。

This library,即使被放弃,也应该给你一些关于如何做到这一点的想法(通过捕获 JS 级别的事件并将额外的属性填充到CustomEventdetail 属性中),尽管实现了DialogController (这不是 JSON 可序列化的)我猜会有点棘手。

【讨论】:

  • 为什么会有?如果有的话,它应该在chrome.dart issue tracker&lt;webview&gt; 有很多东西需要支持,比如 WebRequestEventInterface
猜你喜欢
  • 2021-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多