Solved

the so friendly http error?

Posted on 2000-04-19
9
237 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

805 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