黄聪:C#禁止Webbrowser中的脚本错误提示,自动屏蔽弹出窗口
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; namespace Hcsem
{ public class MyWebBrowser : System.Windows.Forms.WebBrowser
{
#region ExtendedWebBrowserSite
class ExtendedWebBrowserSite : WebBrowser.WebBrowserSite, UnsafeNativeMethods.IDocHostShowUI
{
public ExtendedWebBrowserSite(WebBrowser host)
: base(host)
{
}
void UnsafeNativeMethods.IDocHostShowUI.ShowMessage(ref UnsafeNativeMethods._RemotableHandle hwnd, string lpstrText, string lpstrCaption, uint dwType, string lpstrHelpFile, uint dwHelpContext, out int plResult)
{
plResult = ;
//TODO:自定义
}
void UnsafeNativeMethods.IDocHostShowUI.ShowHelp(ref UnsafeNativeMethods._RemotableHandle hwnd, string pszHelpFile, uint uCommand, uint dwData, UnsafeNativeMethods.tagPOINT ptMouse, object pDispatchObjectHit)
{
//TODO:自定义
}
} protected override WebBrowserSiteBase CreateWebBrowserSiteBase()
{
return new ExtendedWebBrowserSite(this);
}
#endregion
} public class UnsafeNativeMethods
{
#region IDocHostShowUI
[StructLayout(LayoutKind.Explicit, Pack = )]
public struct __MIDL_IWinTypes_0009
{
// Fields
[FieldOffset()]
public int hInproc;
[FieldOffset()]
public int hRemote;
} [StructLayout(LayoutKind.Sequential, Pack = )]
public struct _RemotableHandle
{
public int fContext;
public __MIDL_IWinTypes_0009 u;
} [StructLayout(LayoutKind.Sequential, Pack = )]
public struct tagPOINT
{
public int x;
public int y;
} [ComImport, Guid("C4D244B0-D43E-11CF-893B-00AA00BDCE1A"), InterfaceType((short))]
public interface IDocHostShowUI
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void ShowMessage([In, ComAliasName("ExtendedWebBrowser2.UnsafeNativeMethods.wireHWND")] ref _RemotableHandle hwnd, [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrText, [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrCaption, [In] uint dwType, [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrHelpFile, [In] uint dwHelpContext, [ComAliasName("ExtendedWebBrowser2.UnsafeNativeMethods.LONG_PTR")] out int plResult);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void ShowHelp([In, ComAliasName("ExtendedWebBrowser2.UnsafeNativeMethods.wireHWND")] ref _RemotableHandle hwnd, [In, MarshalAs(UnmanagedType.LPWStr)] string pszHelpFile, [In] uint uCommand, [In] uint dwData, [In] tagPOINT ptMouse, [Out, MarshalAs(UnmanagedType.IDispatch)] object pDispatchObjectHit);
}
#endregion }
}
黄聪:C#禁止Webbrowser中的脚本错误提示,自动屏蔽弹出窗口的更多相关文章
- selenium中处理不带ID的弹出窗口
在selenium中虽然有selectWindow(String windowID) 方法,但是对于一些窗口很难取得其window ID的话,如果开发人员没有在html代码中提供ID ,或者getAl ...
- JS中,根据div数值判断弹出窗口
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 经验总结:WebBrowser自动点击弹出提示框alert、弹出对话框confirm、屏蔽弹出框、屏蔽弹出脚本错误的解决办法
经验总结:WebBrowser自动点击弹出提示框alert.弹出对话框confirm.屏蔽弹出框.屏蔽弹出脚本错误的解决办法 网上有好多解决方法,可是不一定好使,本人经过多次试验,针对WebBrows ...
- form WebBrowser自动点击弹出提示框alert、弹出对话框confirm、屏蔽弹出框、屏蔽弹出脚本错误的解决办法
针对WebBrowser控件中自动点击弹出框及禁用脚本提示问题得到如下几种实际情况的解决办法,绝对管用. 1.屏蔽弹出错误脚本 将WebBrowser控件ScriptErrorsSuppressed设 ...
- WPF的WebBrowser屏蔽弹出脚本错误窗体
WPF自带的WebBrowser在訪问一些有问题的网页时常常跳出非常多提示脚本错误的窗体, 可是WPF没有自带屏蔽这些窗体的方法或属性. 所以网上找来一使用反射的方法来屏蔽弹出脚本错误窗体的方法, 非 ...
- [转]js中confirm实现执行操作前弹出确认框的方法
原文地址:http://www.jb51.net/article/56986.htm 本文实例讲述了js中confirm实现执行操作前弹出确认框的方法.分享给大家供大家参考.具体实现方法如下: 现在在 ...
- 在HTML网页中设置弹出窗口的办法
[1.最基本的弹出窗口代码] 其实代码非常简单: <SCRIPT LANGUAGE="javascript"> <!-- window.open ('page.h ...
- javascript 中的console.log和弹出窗口alert
主要是方便你调式javascript用的.你可以看到你在页面中输出的内容. 相比alert他的优点是: 他能看到结构话的东西,如果是alert,淡出一个对象就是[object object],但是co ...
- WPF WebBrowser屏蔽弹出alert ,confirm ,prompt ,showModalDialog() ,window.open()
WPF WebBrowser屏蔽弹出alert ,confirm ,prompt ,showModalDialog() ,window.open()添加Microsoft.mshtml.dll,然后写 ...
随机推荐
- tools/build.c
/* * linux/tools/build.c * * Copyright (C) 1991, 1992 Linus Torvalds */ /* * This file builds a d ...
- c 函数及指针学习 10
标准库函数 1算数运算stdlib.h 2随机数stdlib.h 3字符串转化stdlib.h 4数学函数 math.h 5日期和时间 time.h 6信号 signal.h 7打印可变参数列表std ...
- Eclipse中web-inf和meta-inf文件夹的信息
http://www.cnblogs.com/chinafine/archive/2010/06/13/1757514.html WEB-INF /WEB-INF/web.xml ...
- 越狱Season 1-Episode 12:Odd Man Out
Season 1-Episode 12:Odd Man Out -Sorry to keep you waiting. 抱歉让你等了半天 -Oh, it's, uh, not a problem. 嗯 ...
- linux下删除所有.svn目录
linux下删除所有.svn目录方法为 find . -type d -name ".svn"|xargs rm -rf 或者 find . -type d -i ...
- audition输出参数设置
- lucene 基本原理整理
基本原理:http://www.cnblogs.com/forfuture1978/archive/2009/12/14/1623594.html 所有过程:http://www.cnblogs.co ...
- loadrunner---<二>---菜鸟对cookie的思考
http://www.cnblogs.com/Pierre-de-Ronsard/archive/2012/11/19/2772630.html loadrunner---<二>---菜鸟 ...
- easyUI之Form(表单)组件
一.对于在easyui中使用的组件,具有输入.输出功能的使用<input>标签,其它的使用<div>标签. 二.对于<input>标签,在使用过程,将name属性和 ...
- EDIUS设置采集磁带的方法
EDIUS作为一款应用广泛的非线性视频编辑软件,将磁带记录的视频信号采集为可以编辑的数字视频信号的使用还是十分广泛的,毕竟磁带不同于数字存储单元,它在批量化的视频录制中表现出很大的优势.下面,小编跟大 ...