In 99% of circumstances I'm against such a thing, but then I started thinking, "what about embedded IE instances? Or cases where people refuse to install a popup blocker for some ungodly reason?".
So thanks to AngieX's ever vigilant and unceasing question on this subject, I finally broke down and created a basic Pop-up blocker for IE as a proof of concept for people to improve upon:
dim x
x=0
'Infinite Loop
While x=0
WScript.Sleep 2000
dim objShell
dim objShellWindows
set objShell = CreateObject("Shell.Application")
' a collection of the open windows that belong to the Shell
set objShellWindows = objShell.Windows
set WshShell = WScript.CreateObject("WScript.Shell")
'If its a valid, displayable window
If (not objShellWindows is nothing) then
dim objIE
dim IE
'For each internet explorer object
For Each objIE in objShellWindows
If (not objIE is nothing) then
If isObject(objIE.Document) Then
Set IE = objIE.Document
'For Each IE object that isn't an activex control
If VarType(IE) = 8 Then
'If the window was opened by another window
If IE.parentWindow.opener = "[object]" Then
objIE.Quit
End If
End If
End If
End if
Set IE = nothing
set objIE = nothing
Next
End if
set objShellWindows = nothing
set objShell = nothing
Wend
The only Issues I see with this are:
1.- it'll run forever until you stop it with the task manager
2.-You have to start this manually everytime you start windows
3.-It'll close popups once every 2 seconds (which you can adjust)
4.-
If the popup opens a popup window of its own, then an error will occur (I didn't check wether window.opener was closed or not first)
All of these minor issues could be fixed without too much effort if someone had the desire to actually use a code lik this.
<message edited by TNO on Thursday, November 13, 2008 5:23 AM>