Webbrowser control - how to display only ONE specific html file
Hello,
I am using a web browser control on a VB form to display html files from a mapped drive on the network. I am not sure if this is the best way to do what i want, but the code was already there so I have just started using it. I want to display say e.g., there is an html file About 123.html and I want to display this file, I use the Navigate method with complete path and name of the file. Now, the problem is the web browser control first goes to the Default.htm file in the same folder (which is the intranet folder) and displays the whole intranet in the web browser and then goes to the file in question.
All I want is to be able to display the About 123.html and that's it. How can I do this??
Re: Webbrowser control - how to display only ONE specific html file
Moved to Classic VB Forum. :)
Re: Webbrowser control - how to display only ONE specific html file
Could you post your code?
Re: Webbrowser control - how to display only ONE specific html file
Sure, here is the code. However, I just noticed that it seems to be working sometimes and other times not. So, I m not too worried about it now. Although, I would like to know if there is anything I m doing wrong.
VB Code:
strAboutFile = Dir(CONST_DIR & "\About " & Me.lstFileName.List(lstFileName.ListIndex) & ".htm")
If strAboutFile = "" Then
strAboutFile = Dir(CONST_DIR & "\NoHelpFile.htm")
Me.lstHelpFiles.AddItem "TemplateList", 0
Me.lstHelpFiles.AddItem "NoHelpFile", 1
Else
Me.lstHelpFiles.AddItem "TemplateList", 0
Me.lstHelpFiles.AddItem "About " & Me.lstFileName.List(lstFileName.ListIndex), 1
End If
'Me.lstHelpFiles.AddItem strAboutFile
Me.WebBrowser.Navigate2 CONST_DIR & strAboutFile
- strAboutFile holds the name of the html file to be displayed
- lstHelpFiles is a list box of documents to choose from - html file relates to the selection made
- CONST_DIR contains the absolute path of the html file
Thanks,
Re: Webbrowser control - how to display only ONE specific html file
This doesn't seem to be a problem with the WebBrowser control. Your strAboutFile variable doesn't seem to hold the correct value. Just put a breakpoint on the last line and check the value of CONST_DIR & strAboutFile.
Moreover I think the correct line should be:
VB Code:
Me.WebBrowser.Navigate2 CONST_DIR & "\" & strAboutFile