CppWebBrowser如何得知某個frame 的原始碼. |
缺席
|
white
一般會員 發表:18 回覆:7 積分:5 註冊:2003-02-17 發送簡訊給我 |
請問CppWebBrowser如何得知某個frame 的原始碼. 我的網頁有3個frame,要定時取得MainFrame目前的原始碼來分析,但不能直接用CppWebBrowser或nnhttp之類元件讀入MainFrame該載入的網頁,因為HideFrame,MainFrame有依存關係,HideFrame會依情況通知MainFrame該載入什麼php,所以一定要同時存在. <frameset rows="100%,*" frameborder="NO" border="0" framespacing="0">
<frame name="MainFrame" src='<? if(substr($loginname,0,1)=='s' || substr($loginname,0,1)=='S' || $CFG_Accs==true)echo "reports"; else echo "control";echo ".php?Lang=$Lang&uid=$uid"; ?>'>
<frame name="HideFrame" src='reftime.php?uid=<?echo "$uid&run=$run";?>'>
</frameset> white
------
white |
white
一般會員 發表:18 回覆:7 積分:5 註冊:2003-02-17 發送簡訊給我 |
|
fizzy
一般會員 發表:0 回覆:4 積分:0 註冊:2005-10-27 發送簡訊給我 |
引言: 找到 OlePropertyGet("Frames") 了,這問題收回.不好意思!! white能否請說明一下,因為我也遇到相關的問題,當我去Refresh網頁時(程式碼如下) CppWebBrowser1->Refresh(); while(CppWebBrowser1->ReadyState!=Shdocvw_tlb::READYSTATE_COMPLETE) { Application->ProcessMessages(); } Variant doc = CppWebBrowser1->ControlInterface->Document; if (((IDispatch *)doc) != NULL) { Variant body = doc.OlePropertyGet("Body"); Variant html = body.OlePropertyGet("InnerHTML"); // Variant frame = body.OlePropertyGet("Frames"); } 程式只是去讀到Frame(Variant html值如下) <FRAME src="/test.jsp?pId=A123456789"></i> 而不是真正顯示出Frame裡面的內容,請問我應該怎麼做,先謝謝回答了!! |
fizzy
一般會員 發表:0 回覆:4 積分:0 註冊:2005-10-27 發送簡訊給我 |
我也收回我的問題!!我在http://c.developpez.com/faq/bcb/?page=composantstcppwebbrowser找到了答案,POST上來讓大家參考參考!
Variant vDocument = Browser->ControlInterface->Document;
if (((IDispatch *)vDocument) != NULL)
{
Variant vFrames = vDocument.OlePropertyGet("Frames");
Variant vFramesCount = vFrames.OlePropertyGet("Length");
for (int i = 0 ; i < vFramesCount ; i )
{
Variant vFrame = vFrames.OleFunction("Item",i);
Variant vFrameDocument = vFrame.OlePropertyGet("Document");
if (((IDispatch *)vFrameDocument) != NULL)
{
ListBox1->Items->Add(vFrameDocument.OlePropertyGet("URL"));
}
}
}
以上為抓出每一Frame的URL,將ListBox1->Items->Add()那列,改成
Variant body = vFrameDocument.OlePropertyGet("Body");
Variant html = body.OlePropertyGet("InnerHTML");
便能將每一Frame裡面的資料給抓出來了!!(如下)
Variant vDocument = Browser->ControlInterface->Document;
if (((IDispatch *)vDocument) != NULL)
{
Variant vFrames = vDocument.OlePropertyGet("Frames");
Variant vFramesCount = vFrames.OlePropertyGet("Length");
for (int i = 0 ; i < vFramesCount ; i )
{
Variant vFrame = vFrames.OleFunction("Item",i);
Variant vFrameDocument = vFrame.OlePropertyGet("Document");
if (((IDispatch *)vFrameDocument) != NULL)
{
Variant body = vFrameDocument.OlePropertyGet("Body");
Variant html = body.OlePropertyGet("InnerHTML");
}
}
}
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |