Solved

the so friendly http error?

Posted on 2000-04-19
9
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

732 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