如何能不弹出webbrowser访问网页时有时出现的脚本错误对话框?
WebBrowser1.Silent :=True;这个方法不行,同样会弹出脚本错误对话框,
WebBrowser1.Silent :=True;这个方法不行,同样会弹出脚本错误对话框,
解决方案 »
- 怎样获取控件集的图标?
- delphi 读取指针数组的数据问题
- DELPHI TAB的问题
- 100分求答案!我电脑有些扫描仪扫描出来的图像,现在我想知道这些图像当时以多少分辨率扫描?
- 把以unicode编码的字符串转化成以gb编码的字符串(有gb--unicode的编码函数)
- 用tcpclient如何使用代理服务器?
- 请问:取字符串从右起的n个字符,用什么函数
- 用过wise installer的请进
- 诸位有没有从国企跳出来的经验?!偶实在是想出来啊,可合同是5年,违约金5万!急!
- 大侠援手,有疑难问题需解决
- 请教快速导入Excel表到Access数据库中的方法。
- 使用select * into temp FROM OpenDataSource进行数据导入出现的问题
要具体说出怎样实现才可以啊 cronuz(cronus) :
可能你遇到的情况比较少
STDMETHODIMP CMyBrowser::Exec( const GUID* pguidCmdGroup, DWORD nCmdID,
DWORD nCmdexecopt, VARIANTARG* pvaIn, VARIANTARG* pvaOut )
{ HRESULT hr = S_OK; if (pguidCmdGroup && IsEqualGUID(*pguidCmdGroup, CGID_DocHostCommandHandler))
{
switch (nCmdID)
{
case OLECMDID_SHOWSCRIPTERROR:
{
IHTMLDocument2* pDoc = NULL;
IHTMLWindow2* pWindow = NULL;
IHTMLEventObj* pEventObj = NULL;
BSTR rgwszNames[5] =
{
SysAllocString(L"errorLine"),
SysAllocString(L"errorCharacter"),
SysAllocString(L"errorCode"),
SysAllocString(L"errorMessage"),
SysAllocString(L"errorUrl")
};
DISPID rgDispIDs[5];
VARIANT rgvaEventInfo[5];
DISPPARAMS params;
BOOL fContinueRunningScripts = true;
int i; params.cArgs = 0;
params.cNamedArgs = 0; // Get the document that is currently being viewed.
hr = pvaIn->punkVal->QueryInterface(IID_IHTMLDocument2, (void **) &pDoc);
// Get document.parentWindow.
hr = pDoc->get_parentWindow(&pWindow);
pDoc->Release();
// Get the window.event object.
hr = pWindow->get_event(&pEventObj);
// Get the error info from the window.event object.
for (i = 0; i < 5; i++)
{
// Get the property's dispID.
hr = pEventObj->GetIDsOfNames(IID_NULL, &rgwszNames[i], 1,
LOCALE_SYSTEM_DEFAULT, &rgDispIDs[i]);
// Get the value of the property.
hr = pEventObj->Invoke(rgDispIDs[i], IID_NULL,
LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, ¶ms, &rgvaEventInfo[i],
NULL, NULL);
SysFreeString(rgwszNames[i]);
} // At this point, you would normally alert the user with
// the information about the error, which is now contained
// in rgvaEventInfo[]. Or, you could just exit silently. (*pvaOut).vt = VT_BOOL;
if (fContinueRunningScripts)
{
// Continue running scripts on the page.
(*pvaOut).boolVal = VARIANT_TRUE;
}
else
{
// Stop running scripts on the page.
(*pvaOut).boolVal = VARIANT_FALSE;
}
break;
}
default:
hr = OLECMDERR_E_NOTSUPPORTED;
break;
}
}
else
{
hr = OLECMDERR_E_UNKNOWNGROUP;
}
return (hr);
}
try
{
//访问代码
}
catch(e){}
</script>
就无错误提示了
//↑加到{Private declaration}procedure TForm1.WMActivate(var Msg: TWMActivate);
var
S: String;
wnd: HWND;
I: Integer;
begin
If Msg.Active=0 then
begin
wnd := Msg.ActiveWindow;
I := GetWindowTextLength(wnd);
SetLength(S, I + 1);
//the text of the specified window's title bar
GetWindowText(Wnd, PChar(S), I + 1);
If Pos('Internet Explorer', S) > 0 then
Sendmessage(wnd,WM_CLOSE,0,0);
end;
end;説明:楼主想必NI自己己解決了、不過試試看、
此方法可屏蔽対話框的出現。