怎样获得webbrowser的所有代码,包括head,就像"查看源代码"或自动另存为htm文件也可以

ncco 2003-04-19 07:03:55
最好是能直接获得所有的,而innerhtml好像只能是body
我该怎么办呢?

想获得所有的html,就像ie"查看源代码"那样的内容,

如果实在不行,可以存为一个磁盘文件的方法也可以,用什么语句?

要包括head

...全文
168 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
huzhiyan11111 2003-09-04
  • 打赏
  • 举报
回复
Loading HTML content from a Stream
void myObject::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
HRESULT hr;
IUnknown* pUnkBrowser = NULL;
IUnknown* pUnkDisp = NULL;
IStream* pStream = NULL;
HGLOBAL hHTMLText;
static TCHAR szHTMLText[] = "<html><h1>Stream Test</h1><p>This HTML content is/
being loaded from a stream.</html>";

// Is this the DocumentComplete event for the top frame window?
// Check COM identity: compare IUnknown interface pointers.
hr = m_pBrowser->QueryInterface( IID_IUnknown, (void**)&pUnkBrowser );
if ( SUCCEEDED(hr) )
{
hr = pDisp->QueryInterface( IID_IUnknown, (void**)&pUnkDisp );
if ( SUCCEEDED(hr) )
{
if ( pUnkBrowser == pUnkDisp )
{ // This is the DocumentComplete event for the top frame - page is loaded!
// Create a stream containing the HTML.
// Alternatively, this stream may have been passed to us.

size_t = cchLength;
// TODO: safely determine the length of szHTMLText in TCHAR.
hHTMLText = GlobalAlloc( GPTR, cchLength+1 );

if ( hHTMLText )
{
size_t cchMax = 256;
StringCchCopy((TCHAR*)hHTMLText, cchMax + 1, szHTMLText);
// TODO: add error handling code here.

hr = CreateStreamOnHGlobal( hHTMLText, TRUE, &pStream );
if ( SUCCEEDED(hr) )
{
// Call the helper function to load the Web Browser from the stream.
LoadWebBrowserFromStream( m_pBrowser, pStream );
pStream->Release();
}
GlobalFree( hHTMLText );
}
}
pUnkDisp->Release();
}
pUnkBrowser->Release();
}
}
a11s 2003-08-09
  • 打赏
  • 举报
回复
我也想知道,帮你顶!
ncco 2003-04-20
  • 打赏
  • 举报
回复
实时错误'600'
could not set the innerhtml property ,invalid target element for this opertaion
imur 2003-04-20
  • 打赏
  • 举报
回复
高人!
ncco 2003-04-19
  • 打赏
  • 举报
回复
谢谢,不过和查看源代码有一定的区别,少了很多换行,奇怪,不过还好可以编程识别。。(我本来是按行的)


怎样写入呢webbrowser,包括head

antshome 2003-04-19
  • 打赏
  • 举报
回复
WebBrowser1.Document.DocumentElement.innerHTML
ncco 2003-04-19
  • 打赏
  • 举报
回复
另外,如何向一个webbroswser写入全部的html,包括head,
我的写进去,只有body管用好像
antshome 2003-04-19
  • 打赏
  • 举报
回复
WebBrowser1.Document.DocumentElement.innerHTML="<html><head><title>测试</title></head></html>"

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧