Solved

WebBrowser control navigation...

Posted on 2004-08-01
7
1,016 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
[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
  • 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
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!

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 - Scroll Mouse wheel on Picturebox 13 118
Collapse and expand table in Word 2010 2 153
Fastest way to find and count same items VB6 16 62
SQL Server 2012 to SQL Server 2016 24 53
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
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…

738 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