如果只是要显示部分的,webbrowser1documentall("body")innerHTML 即可获得<body></body>之间的内容。
否则,建议按照下面网址的做法可以获得完整源码。
>
你说的这个办法其实挺不错的。也可以搜索一下关键词“进程间通信(IPC)”
另外可以还可以使用共享内存的方法,在net中可以使用MemoryMappedFile类来进行共享内存 *** 作,由一个应用程序将Html写入到内存中,再由另一个应用程序从内存中读取出来并显示到WebBrowser中。
可以将这两个程序分别考虑为服务器与客户端,只不过共享数据的方式并非通过Tcp或>
“服务端“代码如下
using System;using SystemCollectionsGeneric;
using SystemLinq;
using SystemText;
using SystemIOMemoryMappedFiles;
using SystemIO;
namespace Memshare
{
class Program
{
static MemoryMappedFile mmf;
static void Main(string[] args)
{
string sampleHtmlString =
@"<html>
<head></head>
<body>
<span>hello world</span>
</body>
</html>";
mmf = MemoryMappedFileCreateNew("sharedHtmlString", 10240, MemoryMappedFileAccessReadWriteExecute);
using (var stream = mmfCreateViewStream())
{
var writer = new BinaryWriter(stream);
writerWrite(sampleHtmlString);
}
ConsoleWriteLine("Waiting!");
ConsoleRead();
}
}
}
“客户端”代码如下
using System;using SystemCollectionsGeneric;
using SystemComponentModel;
using SystemData;
using SystemDrawing;
using SystemLinq;
using SystemText;
using SystemWindowsForms;
using SystemIOMemoryMappedFiles;
using SystemIO;
namespace MemshareClient
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string htmlString = null;
using (var mmf = MemoryMappedFileOpenExisting("sharedHtmlString", MemoryMappedFileRightsReadWrite))
{
using (var stream = mmfCreateViewStream())
{
var reader = new BinaryReader(stream);
htmlString = readerReadString();
}
}
thiswebBrowserDocumentText = htmlString;
}
}
}
HtmlDocument doc= webBrowser1DocumentWindowFrames["frame1"]Document;
HtmlElement el= docGetElementById("input的ID");
elSetAttribute("value","111");
以上就是关于VB WebBrowser中显示网页的HTML源代码.........................全部的内容,包括:VB WebBrowser中显示网页的HTML源代码.........................、C# webbrowser中如何去查找打开网页后所显示的内容,html源码中查不到数据。WebBrowserDocumentCompleted、C#, WebBrowser如何打开内存中的Html source等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)