Solved

the so friendly http error?

Posted on 2000-04-19
9
238 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

830 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