VBScript PopUp Blocker

Author Message
TNO

  • Total Posts : 2094
  • Scores: 36
  • Reward points : 0
  • Joined: 12/18/2004
  • Location: Earth
  • Status: offline
VBScript PopUp Blocker Thursday, January 11, 2007 4:50 AM (permalink)
0
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>
To iterate is human, to recurse divine. -- L. Peter Deutsch
 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9