【问题标题】:How to resolve "Make sure the web address //ieframe.dll/dnserrordiagoff.htm# is correct" error in wxWebView (wxWidgets)如何解决 wxWebView (wxWidgets) 中的“确保网址//ieframe.dll/dnserrordiagoff.htm# 正确”错误
【发布时间】:2022-11-10 01:50:19
【问题描述】:

我正在使用 wxWebView 显示我们的页面内容,当我没有页面的任何内容时,即页面为空白,我看到以下错误:

我有我自己的从wxWebViewHandler 派生的文件系统处理程序类,如下所示,在GetFile 函数中,我设置了页面的内容。一切正常,除非页面没有任何内容。也许我应该返回其他东西。

struct WxHtmlFSHandler: public wxWebViewHandler
{
  WxHtml* dst_;

  WxHtmlFSHandler( const wxString& scheme, WxHtml* dst ): wxWebViewHandler( scheme ), dst_( dst )
  { }

  wxFSFile* GetFile( const wxString& uri ) override;

  ~WxHtmlFSHandler()
  {
    dst_ = nullptr;
  }
};


...

if( dst_ && !uri.empty() )
  {
    if( uri.Contains( dst_->defaultURL_ ) )
    {
      // load the page's content 
      //if( !dst_->currentPage_.empty() )
        return new wxFSFile( new wxMemoryInputStream( dst_->currentPage_.data(), dst_->currentPage_.size() ),
          uri, wxT( "text/html" ), dst_->currentAnchor_
  #if wxUSE_DATETIME
          , wxDateTime::Now()
  #endif
        );
      ...
   }

我现在也在使用 IE 引擎。

#if wxUSE_WEBVIEW_IE
  wxWebViewIE::MSWSetEmulationLevel( wxWEBVIEWIE_EMU_IE11 );
#endif

我在 Win 10 上使用 wxWidgets 3.1.5。

【问题讨论】:

  • 你预计会发生什么?
  • @Igor 我希望什么也看不见!没有任何内容的空白页面。但是那些错误来了
  • 该页面实际上不是空白 - 它不正确。引擎会通知您。只是做你所做的应该是正确的方式
  • @Igor 给一些基本的标签,比如<html><head></head><body></body></html>,而不是一个简单的空格不是更好吗?
  • 大概。但是你应该检查它是否会这样做。如果它会 - 那么是的 - 它会更好(至少在维护方面)。

标签: c++ internet-explorer wxwidgets


【解决方案1】:

所以问题是页面内容为空时。所以我只是尝试在我的内存输入流中添加一个空格字符,如下所示,看看效果。它似乎工作!

基本上我换了

return new wxFSFile( new wxMemoryInputStream( "", 0 ),
          uri, wxT( "text/html" ), dst_->currentAnchor_
#if wxUSE_DATETIME
          , wxDateTime::Now()
#endif
);

return new wxFSFile( new wxMemoryInputStream( " ", 1 ),
          uri, wxT( "text/html" ), dst_->currentAnchor_
#if wxUSE_DATETIME
          , wxDateTime::Now()
#endif
);

现在页面是空白的,没有按预期显示任何内容。我不知道这个hack是否好,甚至正确,所以如果有人有更好的答案,请告诉我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-10
    • 2019-09-27
    • 2017-06-13
    • 2022-12-13
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多