While this works perfectly well, I do have a problem if "Script debuging" is
enabled in IE.
I do not download the whole frame structure of the document, because most of
that I do not need.
If the page actually downloaded, however, contains a script, which
references objects in another frame, which I did not download, IE pops up a
message-window saying, that a script error has occurred and asking, if I
would like to start the script debugger.
How can I suppress this message, apart from disabling script debugging in
the IE altogether?
I tried to do a "Browser.Stop" in the "Document_Complete" event, which
supposedly should stop all active content (like animated gif's and scripts),
but this did not work.
--
Dipl.-Ing.(TH) Winfried Kaiser
Fortune Systems GmbH & Co.
Schleswiger Str. 22a, D-24975 Husby, Germany
thanks for the answer.
I forgot to mention, that I was looking for a solution in VB.
The interface there, of course, is much easier (and might have helped you to
identify the parameters more easily.)
What I am doing is:
Dim WithEvents Win As HTMLWindow2
Private Sub Win_onerror(ByVal description As String, ByVal url As String,
ByVal line As Long)
Stop
End Sub
Unfortunately, this routine is not entered on a script error and the
unwanted Browser message pops up!
--
Dipl.-Ing.(TH) Winfried Kaiser
Fortune Systems GmbH & Co.
Schleswiger Str. 22a, D-24975 Husby, Germany
"Jan Ostedt" <ost...@algonet.se> schrieb im Newsbeitrag
news:bffritses5bsc5lgc...@4ax.com...
Hope this helps.
Fred
"Winfried Kaiser" <WKa...@fortune.de> wrote in message
news:#7J9MtU#AHA.2016@tkmsftngp03...
Although I have managed now to invoke the "Win_onerror" event (by setting
the Windows Reference in the "Download_Complete"-Event like "Set
Win=InternetExplorer1.Document.parentWindow"), this does not help too much!
The problem is, that, if the Explorer advanced Options "Disable Script
debugging" and "Show Script errors" (or however they might be called in the
english version) are not set to "Disable Script debugging" and "Do not show
Script errors" then, either the script debugger invocation or script error
messages are displayed. And only after this message is processed by the
user, the Win_onerror-event is entered.
So, the only way to solve the problem I could figure out is, to set the a.m.
options in the registry, so that no script error message is displayed at
all.
Of course, to be polite, you should restore the original user setting after
you finish using the IE control.
What I have done is:
Private Declare Function SendMessageByString Lib "user32" Alias
"SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String) As Long
Const ExplorerPath$ = "SOFTWARE\Microsoft\Internet Explorer\Main"
Const ScriptDebuggerKey$ = "Disable Script Debugger"
Const ShowScriptErrorKey$ = "Error Dlg Displayed On Every Error"
Const NewScriptDebuggerKey$ = "yes", NewShowScriptErrorKey$ = "no"
Dim OldScriptDebuggerKey$, OldShowScriptErrorKey$, ChangeDebuggerKey,
ChangeScriptErrorKey
On Loading the form containig the control you add the following:
If RegOpenKey(HKEY_CURRENT_USER, ExplorerPath$, hKey) Then
R& = RegQueryStringValue(hKey, ScriptDebuggerKey$,
OldScriptDebuggerKey$)
R& = RegQueryStringValue(hKey, ShowScriptErrorKey$,
OldShowScriptErrorKey$)
ChangeDebuggerKey = OldScriptDebuggerKey$ <> NewScriptDebuggerKey$
ChangeScriptErrorKey = OldShowScriptErrorKey$ <> NewShowScriptErrorKey$
If ChangeDebuggerKey Or ChangeScriptErrorKey Then
If ChangeDebuggerKey Then
R& = RegSetStringValue(hKey, ScriptDebuggerKey$,
NewScriptDebuggerKey$)
End If
If ChangeScriptErrorKey Then
R& = RegSetStringValue(hKey, ShowScriptErrorKey$,
NewShowScriptErrorKey$)
End If
End If
Call RegCloseKey(hKey)
If ChangeDebuggerKey Or ChangeScriptErrorKey Then
Call RefreshBrowserSettings(ExplorerPath$)
End If
End If
On Unloading the form containig the control you add the following:
If ChangeDebuggerKey Or ChangeScriptErrorKey Then
If RegOpenKey(HKEY_CURRENT_USER, ExplorerPath$, hkey) Then
If ChangeDebuggerKey Then
R& = RegSetStringValue(hkey, ScriptDebuggerKey$,
OldScriptDebuggerKey$)
End If
If ChangeScriptErrorKey Then
R& = RegSetStringValue(hkey, ShowScriptErrorKey$,
OldShowScriptErrorKey$)
End If
Call RegCloseKey(hkey)
Call RefreshBrowserSettings(ExplorerPath$)
End If
End If
Finally add the following routine to notify IE of changed settings:
Private Sub RefreshBrowserSettings(RegKey$)
' Broadcast that some setting changed under some registry key
On Error Resume Next
Const HWND_BROADCAST As Long = 65535
Const WM_SETTINGCHANGE As Long = 26
R& = SendMessageByString(HWND_BROADCAST, WM_SETTINGCHANGE, 0&, RegKey$)
End Sub
Alas, this still does not solve the problem completely! It works, if the
Browser UI is displayed. However, if you hide the browser control, as I do,
the bloody message is still displayed.
So, as a last resort, I am now loading this offending page via WININET and
stuff it into the browser after the download, in order to be able to access
the object model an print the page.
Very awkward behaviour, needs definitely to be corrected by MS.