Solved

WebBrowser control navigation...

Posted on 2004-08-01
7
1,012 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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.
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…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now