设置Web浏览器中加载的自定义HTML的URL [英] Set URL of custom HTML loaded in webbrowser

查看:88
本文介绍了设置Web浏览器中加载的自定义HTML的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 WebBrowser 控件中加载了一些html文本(它的uri变成了"about:blank").现在,我想将其Uri设置为其他内容,而无需导航到该链接.

I have loaded some html text in WebBrowser control (its uri becomes "about:blank"). Now I want to set its Uri to something else without navigating to that link.

我该怎么做?

推荐答案

网络浏览器的文档对象通过URL标记加载数据.MSJ 1996年9月发行的文章使用ActiveX扩展进行统一浏览带来了漂亮的图形互联网到您的桌面"".演示了网址别名和浏览器之间的关系.

The webbrowser's document object loads data via a URL moniker. There is a pretty graph in the MSJ 1996 September issue article "Unified Browsing with ActiveX Extensions Brings the Internet to Your Desktop" demonstrating the the relationship about url monikers and the browser.

您可以通过文档的IPersistStreamInit接口手动将绰号或流加载到文档中.这是Winform的webbrowser类在实现DocumentStream和DocumentText属性时所做的事情.该文档将调用源的IMoniker :: GetDisplayName来获取URL.但是,Windows窗体中的从流中加载"实现未实现IMoniker,并且加载的文档的基址为about:blank.

You can load a moniker or a stream into a document manually via the document's IPersistStreamInit interface. This is what Winform's webbrowser class is doing in its implementation of the DocumentStream and DocumentText properties. The document would call the source's IMoniker::GetDisplayName to get the url. However the load-from-stream implementation in Windows Forms does not implement IMoniker and the loaded document will have a base address of about:blank.

http://www.codeproject中,有一个有关实现url名称的示例..com/KB/miscctrl/csEXWB.aspx .在页面上搜索LoadHtmlIntoBrowser(string html,sBaseUrl).

There is a sample on implementing a url moniker at http://www.codeproject.com/KB/miscctrl/csEXWB.aspx. Search LoadHtmlIntoBrowser(string html, string sBaseUrl) on the page.

这篇关于设置Web浏览器中加载的自定义HTML的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆