I want to have an html page load to an anchor in that page. I can load it on a PC but the code of course doesn’t transfer.
The page with the anchor is store in a listbox in the rowtag next to the viewer.
Var str As String = IniHerd.HelpFolder.URLPath + me.RowTagAt(row)
Would someone please tell me how to write this for MacOS
At first glance, this should work on Mac.
Unfortunately it doesn’t. Not even one without an anchor.
Elsewhere I’ve noticed it has something to do with the
“file:///” and it has to be replaced.
It states that in the LR but I don’t have a replacement for a local file.
I think the ‘.URLPath’ doesn’t include the folder delimiter on the end, so you may need to detect for that.
Thanks. It’s there. Grumble.
BTW. It doesn’t work, if it doesn’t change the page.
it seems LoadUrl wants to have http or https prefix to the url.
don’t know if it accepts file:// ?
I would use the LoadPage method, if the file is on the computer ?
I can do that but (excuse sarcasm) I so wanted the anchor to work.
I also have tried changing file out for http but that wouldn’t work also.
The anchor is part of the url isn’t it? So that should not matter with the LoadPage method.
should jump to the a001 ID for instance, something like the in that html page:
<li id="a001">text here</li>
Apologies. It was a space on the end of the file name that did me in. I split the text file that I had built but it didn’t remove an extra carriage return. It doesn’t even show as an extra space on an editor.
I couldn’t figure out why I couldn’t create a folderitem for the longest.
I can now LoadURL without http.
We had a similar case a few weeks ago, those are nasty bugs. What might help you in future is looking at the variable in the binary view to find such extra characters.
That’s how I found it.
Me What is that? Why do have a “.” on the end?
I thought Mac’s TextEdit would show little things like that.
I opened it in TextWrangler and it showed I still Windows returns. Ugh.
Obviously, anchors do not seem to work in Mac HTMLViewer.
Here is a workaround, which displays the content from the anchor (here, “#example”):
Dim f As folderitem = SpecialFolder.UserHome.child("Downloads").child("anchor.html")
Dim PageContent As String
If f.exists Then
If f <> Nil Then
If f.Exists Then
// Be aware that TextInputStream.Open could raise an exception
Var t As TextInputStream
t = TextInputStream.Open(f)
t.Encoding = Encodings.UTF8
PageContent = t.ReadAll
Catch e As IOException
MessageBox("Error accessing file.")
Dim PageCuts() As String = PageContent.Split("<a href=""#example"">")
HTMLViewer1.LoadPage("<html><body>" + PageCuts(1), FolderItem.TemporaryFile)
I like the messagebox on the end. Thanks