class: clsIeEvents

Tech-Archive recommends: Fix windows errors by optimizing your registry



'------------ start class: clsIeEvents ------------
'Csaba Gabor from Vienna
'http://groups-beta.google.com/group/microsoft.public.vb.6.webdevelopment/browse_frm/thread/54cc6e68ee0e9c55/
'http://groups-beta.google.com/group/microsoft.public.vb.6.webdevelopment/browse_frm/thread/54cc6e68ee0e9c55/
'http://groups-beta.google.com/group/microsoft.public.vb.6.webdevelopment/browse_frm/thread/54cc6e68ee0e9c55/
'http://groups-beta.google.com/group/microsoft.public.vb.6.webdevelopment/browse_frm/thread/b1c0ad120c72fe59/
'http://groups-beta.google.com/group/microsoft.public.vb.6.webdevelopment/browse_frm/thread/b1c0ad120c72fe59/

Option Base 0
Option Explicit
Public WithEvents ieEvent As SHDocVw.InternetExplorer

Private Sub ieEvent_DownloadComplete()
'http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/readystate_1.asp

Dim Matches, Match, DOMelem As Object, RE As Object
Set RE = CreateObject("VBscript.RegExp")
RE.Pattern = "http://[^/]*\.google\.(com|..)/"
RE.Global = True 'Is this necessary/useful?

If (Me.ieEvent.ReadyState >= 3) Then
Set Matches = RE.Execute(Me.ieEvent.LocationURL)
For Each Match In Matches
revisePage Me.ieEvent 'only revise google pages
Exit Sub
Next
End If
End Sub

Sub revisePage(ie As SHDocVw.InternetExplorer)
'When you click Search in Google, you'll be asked to reconfirm
'First part just ensures expected page structure
If TypeName(ie.Document) = "Nothing" Then Exit Sub
If TypeName(ie.Document.getElementById("myGoog")) <> "Nothing" _
Then Exit Sub
If TypeName(ie.Document.getElementsByName("btnG")) = "Nothing" _
Then Exit Sub
Dim aBtnG, i, oScript, fctn, modPage, uid
Set aBtnG = ie.Document.getElementsByName("btnG")
'Simple confirm dialog
fctn = "function btnOverride() {" & vbCrLf & _
" var okP = confirm('Are you sure?'); " & vbCrLf & _
" return(okP); }"
For i = 0 To aBtnG.length - 1
If aBtnG(i).tagName = "INPUT" Then
If aBtnG(i).Type = "submit" Then
'If we have a submit button named btnG
'We first create a new script element
Set oScript = ie.Document.createElement("SCRIPT")
oScript.Id = "myGoog"
oScript.Text = fctn
ie.Document.documentElement.appendChild (oScript)
'Now we attach the onclick behaviour to js func
uid = aBtnG(i).uniqueId
aBtnG(i).Id = uid
ie.Document.parentWindow.setTimeout _
"document.getElementById('" & uid & _
"').onclick=btnOverride;", 10
Exit Sub
End If
End If
Next
End Sub
'------------- end class: clsIeEvents -------------

.


Quantcast