|
-
Aug 20th, 2012, 09:45 AM
#1
Thread Starter
Lively Member
[RESOLVED] HTML Links to local html files in Webbrowser not working
Hi guys,
I am doing a basic HTML Editor and encountered a problem with links to local html pages.
On the left there's a textbox and on the right a Webbrowser.
Everything seems to be working fine until I write links in the textbox:
HTML Code:
<a href="C:\Users\Michel\Desktop\myMSpJ\Project1/index.html"> Page 1</a>
I click but nothing happens. to make sure it's got a value, I right clicked on the link in the browser and clicked " Copy shortcut"
then paste somewhere else to see the value and it was:
HTML Code:
file:///C:/Users/Michel/Desktop/myMSpJ/Project1/index.html
I tried to change the <a href> to:
HTML Code:
<a href="index.html"> Page 1</a>
the page would change into a blank page with "Index.html" written.
clicked the copy shortcut on the link in the browser and the value was: "about: page1.html"
All External Links to the web work fine.
I also noticed that if I saved the textbox content as an html file and open it in another browser( not vb webbrowser), all links work fine!
Any help is welcome,
Mike
-
Aug 20th, 2012, 01:33 PM
#2
Thread Starter
Lively Member
Re: HTML Links to local html files in Webbrowser not working
I gave a look at the thread :
Thread
But it seems to me a different thing, because I want the user to be able to save html files created in the vb app anywhere he wants,
and also be able to open them either in the app own webbrowser ( While creating the html) or in another browser.
So the links cannot be only working targeted to vb webbrowser but to all.
Any help please,
Mike
-
Aug 20th, 2012, 01:51 PM
#3
Re: HTML Links to local html files in Webbrowser not working
So you didn't think file:///C:/Users/Michel/Desktop/myMSpJ/Project1/index.html was important then?
<a href="file:///C:/Users/Michel/Desktop/myMSpJ/Project1/index.html">
Would you leave http:// off a web link?
-
Aug 20th, 2012, 02:49 PM
#4
Thread Starter
Lively Member
Re: HTML Links to local html files in Webbrowser not working
I dont get what you mean
I dont know how it works, but if i have to change the href to target my local files, so it means when i upload my html file to a remote server the links will all be broken and i dont want this, i need flexibility. That's why I was trying <a href="page1.html">
because the index.html file is in the same folder as page1.html
Mike
Last edited by MikeSpider; Aug 20th, 2012 at 02:52 PM.
-
Aug 20th, 2012, 03:41 PM
#5
Re: HTML Links to local html files in Webbrowser not working
Oh right ....
<a href="/page1.html">
-
Aug 20th, 2012, 06:05 PM
#6
Thread Starter
Lively Member
Re: HTML Links to local html files in Webbrowser not working
 Originally Posted by dunfiddlin
Oh right ....
<a href="/page1.html">
It does not work on the vb browser, only on other browsers.
-
Aug 20th, 2012, 06:08 PM
#7
Re: HTML Links to local html files in Webbrowser not working
Works on mine! How are you feeding the value into the html document?
-
Aug 20th, 2012, 06:13 PM
#8
Thread Starter
Lively Member
Re: HTML Links to local html files in Webbrowser not working
it displays a blank page with " /page1.html" written on it.
I wrote it straight into the textbox.
-
Aug 20th, 2012, 06:42 PM
#9
Re: HTML Links to local html files in Webbrowser not working
Right. So there is no html document!? Local href works from the url of the current document. If you don't have an established url then there is no 'local' hence the blank page which is the browser's way of saying "I'm sorry but I don't have a clue what you're talking about!" You have to save the file and then load it into the browser from the full url if you want to see it in action. Once you've established where local is it can proceed from there.
-
Aug 21st, 2012, 07:26 AM
#10
Thread Starter
Lively Member
Re: HTML Links to local html files in Webbrowser not working
There is html document. I have a text changed event in the textbox which saves automatically as html, the html is then loaded in the webbrowser.
-
Aug 21st, 2012, 07:43 AM
#11
Re: HTML Links to local html files in Webbrowser not working
Can we see that section of the code then, please?
-
Aug 21st, 2012, 08:16 AM
#12
Thread Starter
Lively Member
Re: HTML Links to local html files in Webbrowser not working
sure
But i dont think the problem is there, because even the image url in the background-image in the css file does not work. I think all local urls are not working on VB webbrowser, and as I said b4 urls need to be working in all browsers including VB .
Code:
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
If realTimeChange = True Then
If fn.Contains(".css") Or fn.Contains(".js") Then
If My.Computer.FileSystem.FileExists(LastActivePage) Then
My.Computer.FileSystem.WriteAllText(fn, RichTextBox1.Text, False)
ScriptOutput.DocumentText = My.Computer.FileSystem.ReadAllText(LastActivePage)
Else
ScriptOutput.DocumentText = ""
End If
Else
My.Computer.FileSystem.WriteAllText(fn, RichTextBox1.Text, False)
ScriptOutput.DocumentText = My.Computer.FileSystem.ReadAllText(fn)
End If
End If
End Sub
Thanks,
Mike
-
Aug 21st, 2012, 08:29 AM
#13
Re: HTML Links to local html files in Webbrowser not working
Yes, the problem is there because you're reading the file into a document not navigating to it. All browsers parse 'local' links relative to the current url. Because you're bypassing navigation there is no url to be relative to. Local/relative links work just fine in the VB WebBrowser when they're part of an html document whose file location it has been given.
-
Aug 22nd, 2012, 09:26 AM
#14
Thread Starter
Lively Member
Re: HTML Links to local html files in Webbrowser not working
OK. So how can I sort this problem?
Can you help me please?
Thanks,
Mike
-
Aug 22nd, 2012, 09:46 AM
#15
Thread Starter
Lively Member
Re: HTML Links to local html files in Webbrowser not working
Alright, I sorted it out using the Navigate
Code:
ScriptOutput.Navigate(LastActivePage)
But there's a small problem though, if I cut the link "C:\Users\Michel\Desktop\Mike site\Site\page1.html" to just "page1.html",
the link becomes invisible, although is still functional, I mean I can click it but I cannot see it. Any ideias as to where the problem might be?
Thanks a lot,
Mike
-
Aug 22nd, 2012, 10:41 AM
#16
Re: HTML Links to local html files in Webbrowser not working
Have you set font styles/colour etc. anywhere? The most likely explanation if the link is there but not seen that you have inadvertently changed the background to the same colour as the font or the font to the same colour as the background. This could be as a style for links although it's not the default, which as you know is blue for unvisited links, purple for visited ones.
-
Aug 22nd, 2012, 10:49 AM
#17
Thread Starter
Lively Member
Re: HTML Links to local html files in Webbrowser not working
 Originally Posted by dunfiddlin
Have you set font styles/colour etc. anywhere? The most likely explanation if the link is there but not seen that you have inadvertently changed the background to the same colour as the font or the font to the same colour as the background. This could be as a style for links although it's not the default, which as you know is blue for unvisited links, purple for visited ones.
lol you are right! my distraction.
Thanks a Lot 
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|