简体   繁体   English

禁用JavaScript弹出错误

[英]Disable javascript pop-up error

I have a Windows application where I use the WebBrowser control. 我有一个Windows应用程序,可以在其中使用WebBrowser控件。 The WebBrowser shows an html page created dynamically using javascript and xml. WebBrowser显示使用javascript和xml动态创建的html页面。

This html page runs a new pop-up window. 该html页面运行一个新的弹出窗口。 It works very well. 效果很好。 But when I am closing the pop-up window I get the two errors: 但是,当我关闭弹出窗口时,出现两个错误:

  1. It was not possible to set value of property 'CpGetValue' value of object is Null or it isn't defined; 无法设置属性“ CpGetValue”的值,对象的值为Null或未定义;
  2. It was not possible to set value of property 'CpSetValue' value of object is Null or it isn't defined. 无法设置属性“ CpSetValue”的值,对象的值为Null或未定义。

I looked for these properties but I can't find them. 我在寻找这些属性,但找不到它们。 I used the tips to disable JavaScript errors in the WebBrowser but I can't stop this error. 我使用了提示来禁用WebBrowser中的JavaScript错误,但无法停止此错误。

SLOPPY SOLUTION 松散的解决方案

If you have access to the html page and you can fix the javascript then do that. 如果您有权访问html页面,并且可以修复javascript,则可以这样做。 Otherwise, you might try the following. 否则,您可以尝试以下方法。

Traverse the DOM of the webbrowser and inject the following javascript to attempt to suppress the errors: 遍历Web浏览器的DOM并注入以下JavaScript以尝试抑制该错误:

<script>window.onerror=function(){return true;}</script> 

See: How to inject Javascript in WebBrowser control? 请参阅: 如何在WebBrowser控件中注入Javascript?

I had a problem awhile ago where I was using a WebBrowser control in a C# app and there was a link that created a pop-up window: the pop-up window did not maintain the same session/cookie data, so I ended up having to post the data I needed. 不久前,我在C#应用程序中使用WebBrowser控件时遇到问题,并且有一个链接创建了一个弹出窗口:该弹出窗口没有维护相同的会话/ Cookie数据,所以我最终不得不发布我需要的数据。 It sounds like something like that could be causing problems for you, but there's not enough detail to tell. 听起来这可能会给您带来麻烦,但是没有足够的细节可以说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM