如何在mshtml.HTMLDocument(.NET)中禁用Javascript [英] How to disable Javascript in mshtml.HTMLDocument (.NET)

查看:133
本文介绍了如何在mshtml.HTMLDocument(.NET)中禁用Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的代码:

  Dim Document As New mshtml.HTMLDocument 
Dim iDoc As mshtml.IHTMLDocument2 = CType(Document,mshtml.IHTMLDocument2)
iDoc.write(html)
iDoc.close()

然而,当我加载这样一个HTML时,它会执行所有的Javascript以及从html代码请求一些资源。



我想禁用JavaScript和所有其他弹出窗口(如证书错误)。

我的目标是使用mshtml文档中的DOM从HTML中提取一些标签以可靠的方式(而不是一堆正则表达式)。



还是有另一个IE / Office DLL,我可以加载一个HTML wihtout考虑IE相关的弹出窗口或活动脚本?

Dim Document As New mshtml.HTMLDocument
Dim iDoc As mshtml.IHTMLDocument2 = CType(Document,mshtml.IHTMLDocument2)class =h2_lin
'添加此代码
iDoc.designMode =On
iDoc.write(html)iDoc.close()


I've got a code like this :

Dim Document As New mshtml.HTMLDocument
Dim iDoc As mshtml.IHTMLDocument2 = CType(Document, mshtml.IHTMLDocument2)
iDoc.write(html)
iDoc.close()

However when I load an HTML like this it executes all Javascripts in it as well as doing request to some resources from "html" code.

I want to disable javascript and all other popups (such as certificate error).

My aim is to use DOM from mshtml document to extract some tags from the HTML in a reliable way (instead of bunch of regexes).

Or is there another IE/Office DLL which I can just load an HTML wihtout thinking about IE related popups or active scripts?

解决方案

Dim Document As New mshtml.HTMLDocument
Dim iDoc As mshtml.IHTMLDocument2 = CType(Document, mshtml.IHTMLDocument2)
'add this code
iDoc.designMode="On"
iDoc.write(html)iDoc.close()

这篇关于如何在mshtml.HTMLDocument(.NET)中禁用Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆