Solved

the so friendly http error?

Posted on 2000-04-19
9
234 Views
Last Modified: 2010-05-02
may be you all already notice that MSIE was so friendly to load a "user friendly html page(s)" when error occurs during browsing the selected url or files.

but it's not what i want, i like to give  my own error page(s) when my webbrowser object failed to load the selected pages, how can i do this?
0
Comment
Question by:cindafuzzy
  • 4
  • 4
9 Comments
 
LVL 1

Expert Comment

by:ollertonk
ID: 2729987
I'm using IIS4 to run our company intranet and this gives you the option to change the error pages returned to the user.  (Each is just a plain text or HTML page which can be edited).

From this I take it that the error page returned is dependant on the server that is throwing the error and the MSIE page is only displayed if the site doesn't have it's own error page. (I could be wrong about this!)

0
 
LVL 1

Expert Comment

by:derekcmartin
ID: 2730410
I am checking each page as it comes by.  I used the inet1 control.  If an error is returned, I display my own html file.  For more information, go to

http://msdn.microsoft.com/library/techart/msdn_vbhttp.htm
0
 

Author Comment

by:cindafuzzy
ID: 2733226
hi derekcmartin,

the sample from that site works fine, but what really i want is is there any way on doing this with webbrowser control event trigger, ie:

sub webbrowser1_downloadcomplete()

'do what so ever you want.. bla.. bla

sub

with pseudocode look like this

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if user clicked button x then
  set webbrowser1 to open url [http://www.experts-exchange.com]
  if webbrowser1 open failed then
     set webbrowser1 to open url [application path & error.htm]
  endif
endif
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

i hope you can get the idea?, anyway thanks
0
 

Author Comment

by:cindafuzzy
ID: 2733238
one more thing, this application is not desing run on web server only but also locally (fetch html document from harddisk), so any error customization from web server won't be the answer (ie. error page form iis)
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Accepted Solution

by:
derekcmartin earned 76 total points
ID: 2734408
By what you put above, it shows that after the page is loaded from the site, it then navigates.  Here is how I did it.  This works great.  I don't have the browser navigating to the page and then checking.  I do it all before I actually load the page for the user to see.

Try this:

First add an Inet1 control to your project

Public Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)

 Inet1.Execute (URL)

end sub

Public Sub Inet1_StateChanged(ByVal State As Integer)

Dim exiterror As Error

On Error GoTo exiterror
Select Case State


    Case 11
    'This is if there was an error connecting to the host.
     False_MDI_Form.CommonDialog1.CancelError = True       False_MDI_Form.CommonDialog1.FileName = application path & error.htm
        Me.WebBrowser1.Navigate False_MDI_Form.CommonDialog1.FileName
       
        Exit Sub
       
End Select

Dim getheaderstring As String

getheaderstring = Inet1.GetChunk(100)
                'receiving 100 bytes, just enough for the header
If InStr(getheaderstring, "400") Or InStr(getheaderstring, "401") Or InStr(getheaderstring, "403") Or InStr(getheaderstring, "404") Or InStr(getheaderstring, "500") Or InStr(getheaderstring, "501") Or InStr(getheaderstring, "502") Or InStr(getheaderstring, "503") Then
                False_MDI_Form.CommonDialog1.CancelError = True
                False_MDI_Form.CommonDialog1.FileName = application path & error.htm
                Me.WebBrowser1.Navigate False_MDI_Form.CommonDialog1.FileName
                Exit Sub
End If

exiterror:
    Exit Sub
   
   
   
End Sub

0
 
LVL 1

Expert Comment

by:derekcmartin
ID: 2734413
Please omit the false_MDI_Form.  Just use whatever form you are currently on.
0
 

Author Comment

by:cindafuzzy
ID: 2735315
Adjusted points from 75 to 76
0
 

Author Comment

by:cindafuzzy
ID: 2735316
thanks for the answer derek, althought it is not what i hope for but right now it was the best i can get. anyway thanks again... you deserve the points... just plus one more for you :)
0
 
LVL 1

Expert Comment

by:derekcmartin
ID: 2735582
Thanks!  8o)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Formula to Randomize Data Set for Time Series Visual 1 72
DO Loop not working 4 63
Access 2016 VB code 9 86
Adding to a VBA? 6 48
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now