Solved

WebBrowser control navigation...

Posted on 2004-08-01
7
1,015 Views
Last Modified: 2008-02-01
hi,

i've created a webbrowser control and filled it's innerhtml from database. my question is, when i click on a link on the control, it doesn't do anything (on some computers, especially on mine it works fine), but when i try to save the page the link points to, it saves it successfully (base href set correctly in innerhtml)

what should i do to make those links work?
0
Comment
Question by:viktor1983
  • 4
  • 3
7 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 11689159
Check the link's HREF.

For example...
Private Sub Command1_Click()
    WebBrowser1.Navigate "about:blank"
    Do Until WebBrowser1.ReadyState = READYSTATE_COMPLETE
        DoEvents
    Loop
    WebBrowser1.Document.body.innerhtml = "<base href=http://www.yahoo.com><a href=test.html>Test</a>"
End Sub

..causes the link's HREF to be "http://www.yahoo.com/test.html" instead of just "test.html".
0
 

Author Comment

by:viktor1983
ID: 11689254
i know that, base href is set correctly, when i try to save the document, it works perfectly... but when someone tries to open it, it doesn't do anything.... doesn't display error page, nothing.... but it works fine on my computer ;-\
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 11689262
By "Check the link's HREF.", I meant for you to post it here. The HREF of the link for you and the systems it doesn't work on.

>>but it works fine on my computer
If it only works fine for you, it may be due to it being a development-machine. Any references, etc. (such as using "Active Accessibility" (WM_HTML_GETOBJECT)) may be required. It'd help to remove any error-handlers.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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:viktor1983
ID: 11689783
the HREF is built here:

base = "<base href=""" & App.Path & "/data/" & dname & "/"">"

then i put the contents to the webbrowser with the "base":

wb = base & app.Data1.Recordset!szoveg
html_text = base & vbCrLf & wb
WebBrowser1.Document.body.innerHTML = html_text

now i put an msgbox into the app that displays the base href, and it's correct on the computers too that doesn't display the link, the file that the link points to is in it's place, you can save it by clicking on save as... only doesn't display it ;-\

i'm new to vb, so don't be too confused... but what is WM_HTML_GETOBJECT? i've looked for Active Accessibility in the project --> references option, but haven't found anything...

i've made a deployment package, but the results are still the same, and the problem exists... ;(
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 500 total points
ID: 11690140
Ok. I think I've tracked the error down to it causing "Access Denied". How do you originally create the document to modify it?

Such as: WebBrowser1.navigate "about:blank"

If you use "about:blank" originally (or any online site), it's in the zone "Internet" and when in that zone, the browser cannot access files on the local machine. It's a security precaution. Now, if you use "file://c:\test.html", it's in the "My Computer" zone (the name may vary on systems). When in that zone, the browser can access files on the local machine (your hard-drive for example).

Proof of concept:

Private Sub Command1_Click()
    'You cannot click the link for this one...
    WebBrowser1.Navigate "about:blank"
    Do Until WebBrowser1.readyState = READYSTATE_COMPLETE
        DoEvents
    Loop
    WebBrowser1.Document.body.innerHTML = "<a href=file://c:\test.bmp>Test</a>"
End Sub
Private Sub Command2_Click()
    'You CAN click the link for this one...
    WebBrowser1.Navigate "c:\test.html"
    Do Until WebBrowser1.readyState = READYSTATE_COMPLETE
        DoEvents
    Loop
    WebBrowser1.Document.body.innerHTML = "<a href=file://c:\test.bmp>Test</a>"
End Sub
0
 

Author Comment

by:viktor1983
ID: 11690222
i've solved the problem by saving the "contents" to disk, then using navigate2 to get there...

thanks for your advice, i'll try to solve using this :)
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 11690253
Well if what you're doing now works, it's just a "zone" issue as I mentioned. Good luck.
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

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