IEEvent_NewWindow3如何使用
装了搜狗浏览器后IEEvent_NewWindow3 、IEEvent_NewWindow2无法使用,原因是网页中有window.open函数,如何屏蔽这个函数?MSDN的说法如下:
The event is raised during the following actions:
The user clicks a link while pressing the SHIFT or CTRL key.
The user right-clicks a link and selects Open in New Window or Open in New Tab.
There is a targeted navigation to a frame name that does not yet exist, or _blank.
Script invokes window.open.
A browser application calls Navigate or Navigate2 with the navOpenInNewWindow flag.
The application that processes this notification can respond in one of three ways:
Create a new, hidden, non-navigated WebBrowser object or InternetExplorer object that is returned in ppDisp. On return, the object that fired this event configures and navigates (including a BeforeNavigate2 event) the new object to the target location.
Cancel the navigation by setting Cancel to VARIANT_TRUE.
Do nothing and do not set ppDisp to any value. This will cause the object that fired the event to create a new InternetExplorer object as a separate (non-hosted) process to handle the navigation.
按照madn应该是window.open不起作用才对的啊 重定义不知可不可
最后写入网页
<script>window.open = function winopen() {return false;}</script> 怎么写啊?来段代码看看。我没成功 这是禁止网页点击的,上面给的只是个想法(好不好用就不知,多年不玩了,忘光了)
$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, "<script>document.body.onclick=function nopopup(){return false;}</script>", "beforeend")
需要好好看看才行 我是这么搞的
#NoTrayIcon
#include <IE.au3>
Do
$IE = _IECreateEmbedded()
_IELoadWaitTimeout(15000)
_IEPropertySet($IE, 'silent', True)
GUICreate("", 800,600)
GUICtrlCreateObj($IE, 0, 0, 800, 600)
GUISetState()
_IENavigate($IE, "About:Blank")
Until Not @error
_IENavigate($IE, "http://mp3.baidu.com/", 0)
IEHeadInsertScript($IE, "function trackMouseover(){return;}")
IEHeadInsertScript($IE, "function window.open(){return False;}")
Sleep(10000)
Func IEHeadInsertScript($o_object, $s_script)
Local $o_head, $o_element
$o_head = _IETagNameGetCollection($o_object, "head", 0)
$o_element = $o_object.document.createElement('script')
$o_element.type = 'text/javascript'
$o_element.text = $s_script
Return $o_head.appendChild($o_element)
EndFunc 还是不行
Func IEEvent_BeforeNavigate2($pDisp,$URL, $Flags, $TargetFrameName, $PostData, $Headers, $Cancel)
_IEHeadInsertEventScript ($oIE, "document", "oncontextmenu", "alert('请用左键下载');return false")
_IEHeadInsertEventScript($oIE,'document','onclick',_Evt__onClick())
$firturl = $URL
$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, "<script>window.open(){return false;}</script>", "beforebegin")
EndFunc 终于搞定了,是脚本要声明是java script 类型才可以
$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, '<SCRIPT type="text/javascript">window.open(){return false;}</script>', "beforebegin") 不过有的地方还是不行,有点不通用 经过测试,在网页中插入
<SCRIPT language=jscript for=window defer type=text/javascript>function window.open(){return false;}</SCRIPT>
可以屏蔽window.open
可是使用_IEHeadInsertEventScript($oIE,'window','','function window.open(){return false;}')
插入得到的是
<SCRIPT language=jscriptevent="" for=window defer type=text/javascript>function window.open(){return false;}</SCRIPT>
event事件不知道如何设置 是要绝对处理的工程庞大
由于网页设计格式的不同(不知这样说对不对)
要设计相应的方法进行处理
不是简单1\2句代码就能全部搞定的 event="onload"
是不是说网页加载完成了就。。。执行某一动作! 还真是,问题解决了一半了,多谢关注 Target=“_blank " 这种新窗口还不知道如何搞定,概叹接着搞吧。 有没有想过用正则去替换掉整个网页内容中不需要的内容,然后重写
不知能否行得通