Solved

WebBrowser control navigation...

Posted on 2004-08-01
7
1,014 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
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: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

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.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

785 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