一个winforms与网页交互的问题

Utopia_Chen 2008-10-02 07:02:42
IHTMLWindow2 win = (IHTMLWindow2)webBrowser1.Document.Window.DomWindow;
string s = "window.alert = null;\r\nwindow.confirm = null;\r\nwindow.open = null;\r\nwindow.showModalDialog = null;";
win.execScript(s, "javascript");


IHTMLWindow2 是c:\windows\system32\mshtml.tlb 里的接口

就这段代码。功能是禁止网页里弹出对话框。

我的机子能用,把程序给了我朋友,他打开就不起作用了。为什么啊???
...全文
131 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wudeqing 2008-10-03
  • 打赏
  • 举报
回复
IE属性设置里面改
Utopia_Chen 2008-10-02
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 fengyecsdn 的回复:]
你换个写法就OK了

string s = " function alert(strs){} window.alert = null;\r\nwindow.confirm = null;\r\nwindow.open = null;\r\nwindow.showModalDialog = null;";

加上这个function alert(strs){}
[/Quote]

按你的做,连网页都不显示了。。。
Utopia_Chen 2008-10-02
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 Deathsign 的回复:]
IE的版本问题?
[/Quote]

不是IE问题,我2台电脑的IE6 ,7 都能用
Deathsign 2008-10-02
  • 打赏
  • 举报
回复
IE的版本问题?
Utopia_Chen 2008-10-02
  • 打赏
  • 举报
回复
4楼,为啥要加那东西???有什么作用
霜寒月冷 2008-10-02
  • 打赏
  • 举报
回复
晕,初学者。
还没看明白你的代码,先帮你顶下!收藏下。。。。。
fengyecsdn 2008-10-02
  • 打赏
  • 举报
回复
你换个写法就OK了

string s = " function alert(strs){} window.alert = null;\r\nwindow.confirm = null;\r\nwindow.open = null;\r\nwindow.showModalDialog = null;";

加上这个function alert(strs){}
Utopia_Chen 2008-10-02
  • 打赏
  • 举报
回复
1楼啥意思啊,能详细说下这设置在哪么?
liang4571231 2008-10-02
  • 打赏
  • 举报
回复
帮你顶顶
tete 2008-10-02
  • 打赏
  • 举报
回复
可能是环境不同,我觉得有可能调用的windows的设置,所以如果他那边关闭的弹出窗口阻止程序,说不定就不起效了

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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