如题。
是一个网页的错误警告信息窗口,如何屏蔽?或者自动关闭之?
分析过这个网页的代码有如下语句
<script>
alert("对不起,你查询的信息不存在。"); window.close();
</script>在论坛上看到过相似内容的帖子,有人提出在WebBrower的NewWindow2事件里加
Cancel := True;
这个能够对弹出窗口有效,但如上的对话框还是不起作用。
还有一个是VB版本的解决方法,我没有试过
==========================
某些网页出于各种考虑会弹出对话框要求信息确认,往往会中断我们的webbrowser过程,可以使用如下方法:
1.加入Microsoft Html Object
2.加入语句 Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Dim obj As HTMLDocument
Set obj = pDisp.Document
obj.parentWindow.execScript "function showModalDialog(){return;}" '对showModalDialog引起的对话框进行确定
End Sub
而confirm引发的对话确定框可用confirm替换showModalDialog即可,Alert等同理~
=========================
但我在DELPHI里加入代码时,报pDisp.Document 这一行是 Undeclared identifier "Document"
不知道各位大虾有没有好的方法?
看过 蒋晟 MVP给的一个MSDN的参考网页,可惜E文太差,有没有哪位能够将上面VB
版本的改成DELPHI呀,谢谢了。
是一个网页的错误警告信息窗口,如何屏蔽?或者自动关闭之?
分析过这个网页的代码有如下语句
<script>
alert("对不起,你查询的信息不存在。"); window.close();
</script>在论坛上看到过相似内容的帖子,有人提出在WebBrower的NewWindow2事件里加
Cancel := True;
这个能够对弹出窗口有效,但如上的对话框还是不起作用。
还有一个是VB版本的解决方法,我没有试过
==========================
某些网页出于各种考虑会弹出对话框要求信息确认,往往会中断我们的webbrowser过程,可以使用如下方法:
1.加入Microsoft Html Object
2.加入语句 Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Dim obj As HTMLDocument
Set obj = pDisp.Document
obj.parentWindow.execScript "function showModalDialog(){return;}" '对showModalDialog引起的对话框进行确定
End Sub
而confirm引发的对话确定框可用confirm替换showModalDialog即可,Alert等同理~
=========================
但我在DELPHI里加入代码时,报pDisp.Document 这一行是 Undeclared identifier "Document"
不知道各位大虾有没有好的方法?
看过 蒋晟 MVP给的一个MSDN的参考网页,可惜E文太差,有没有哪位能够将上面VB
版本的改成DELPHI呀,谢谢了。
const pDisp: IDispatch; var URL: OleVariant);
var
vDocument: IHTMLDocument2;
begin
vDocument := TWebBrowser(Sender).Document as IHTMLDocument2;
vDocument.parentWindow.execScript(
'function alert(str){return;}', 'javaScript');
end;