Source language: Translate to:

How do I set the root context for URLs in the browser object

General questions about NeoBook

Moderator: Neosoft Support

How do I set the root context for URLs in the browser object

Postby Enigman » Wed Jun 03, 2015 10:54 pm

I have converted my pubs help files from RTF to HTML and now display them using a browser object displayed in a custom window. The browser object embeds all the HTML files inside the pub. I can navigate between internal files just fine. But, if I navigate to an outside website on internet, then from that point on the "context" of the file URLs has changed from internal embedded HTML to external internet URLs. Therefore, after that point any file name sent to the browser is interpretted as being out on internet instead of embedded inside the pub. That means my normal navigation buttons only yield 404 errors from the last internet site I visited.

Does anyone know how to change the context back to internal embedded files instead of internet URLs?

Any help would be appreciated.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Re: How do I set the root context for URLs in the browser ob

Postby dpayer » Thu Jun 04, 2015 6:23 am

Enigman wrote:Does anyone know how to change the context back to internal embedded files instead of internet URLs?

Any help would be appreciated.


I'm not sure if you are using these URLs in a menuing system or in some other manner.

If you create absolute references on all links, it will go to that absolute location meaning [pubdir]htmlfiles\thisfile.htm instead of using thisfile.htm should keep you in your proper reference.

If you are talking about having referenced an internet file and some of the links there are calling resources you don't have control of then you may need to consider rewriting those files once they are downloaded and make them point in the right place.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: How do I set the root context for URLs in the browser ob

Postby Enigman » Thu Jun 04, 2015 9:50 am

:lol: LOL ... a little while ago I typed in a much longer explanation of what my pub was doing and what I wanted to know. In the process of doing that I needed to check some facts against what I wrote, so I started experimenting with my code to verify my statements. In so doing I accidently found the problem and it is related to the BrowserGoto command and how it acts. Here is the deal:

If the BrowserGoto command contains a literal string for the parameter, like this:

Code: Select all
BrowserGoto "Help_Contents.html"

... then it looks internally (or locally) for the file first, and if it is not there, then it looks externally on internet.

If the BrowserGoto command contains a variable for the parameter, like this:

Code: Select all
SetVar "[HelpPage]" "Help_Contents.html"
BrowserGoto "[HelpPage]"

... then it ONLY looks on internet for the file.

In other words, the BrowserGoto command is able to reset the context of the browser object depending on the value of the literal string. If the literal string is a local file, then the context is set to local. If the literal string is an internet URL, then the context becomes internet. BUT, if you use a variable with BrowserGoto, then the context is ALWAYS internet.

If you are only using literal strings with BrowserGoto, then you may not notice this behavior. But I needed to go to specific help pages from buttons on the pub interface, so I was using a subroutine and variables, and because of the perceived wonky behavior of BrowserGoto I had switched to an alternate method of changing pages, like this:

Code: Select all
:OpenHelp

CustomWindow "" "-1" "-1" "HelpBox" "DialogBox"
BrowserExecScript "HelpBrowser" "window.location = '[thisHelpFile].html';" "JScript"

Return

... where the code was executed from a subroutine called by interface help buttons. That worked fine up until a location was typed into the location bar that took the browser to internet. After that none of the interface help buttons worked because the browser context had changed.

The reason is that the BrowserExecScript command does not alter the context of the browser no matter how the file location is specified. It just tries to work under the current context, so if you look for a local file when the context is internet, then you get 404 error pages.

My fix to keep the interface buttons always working was simple. I made an HTML file called "Blank.html" that contained only "<html></html>" and linked it from my "Help_Contents.html" file so that it would compile into the pub. Then I added one step in the subroutine like this:

Code: Select all
:OpenHelp

CustomWindow "" "-1" "-1" "HelpBox" "DialogBox"
BrowserGoto "Blank.html"
BrowserExecScript "HelpBrowser" "window.location = '[thisHelpFile].html';" "JScript"

Return


Invoking the Blank.html as a literal parameter from the BrowserGoto command pulled the browser context back into the embedded files, and from then on I could use a variable based BrowserExecScript command to jump to a specific page.

This behavior of the BrowserGoto command is not documented in the help file, so I don't know if it is a bug, or by design. If it is by design, then it should be added to the help file. If it is a bug, it might be good to unify the behavior so that a literal parameter acts the same as a variable parameter, and then maybe add a context parameter to specify looking internally or externally, maybe like this:

BrowserGoto (variable/literal) (all/internal/local/internet)
... where the target can be either a variable or literal.
... and where the parameter "all" means look sequentially from internal to internet, "internal" means only embedded, "local" means only outside the pub but on disk, and "internet" means only on internet. Likewise the parameter could also be a literal value or from a variable. Such as:

Code: Select all
BrowserGoto  "[thishelpfile]"  "internal"

BrowserGoto  "Help_Contents.html"  "local"

BrowserGoto  "[thishelpfile]"  "[inContext]"

The above would remove all of the uncertainty and make it's behavior consistent with the author's intention.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Re: How do I set the root context for URLs in the browser ob

Postby Neosoft Support » Thu Jun 04, 2015 10:26 am

This behavior of the BrowserGoto command is not documented in the help file, so I don't know if it is a bug, or by design. If it is by design, then it should be added to the help file...


It's very difficult to predict in advance all of the many things people might try to do and add them to the help file. Probably most of the time when users compile HTML content into an exe, they don't also display content from the Internet. (Or they've used a separate browser object.) That doesn't mean someone won't, but it just hasn't come up until now so it's not covered in the help file.

Anyway, another option (also not documented because it's never been needed) would be to use the temporary protocol that NeoBook uses internally to load content compiled inside the exe. This will tell the browser to load content from inside the exe instead of externally (IE's default). For example:

Code: Select all
BrowserExecScript "WebBrowser1" "window.location = 'neobook-ie:Help_Contents.html';" "JScript"


or

Code: Select all
BrowserGoTo "WebBrowser1" "neobook-ie:Help_Contents.html"


Just prefix files names with "neobook-ie:".
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: How do I set the root context for URLs in the browser ob

Postby Enigman » Thu Jun 04, 2015 10:56 am

It's very difficult to predict in advance all of the many things people might try to do and add them to the help file. Probably most of the time when users compile HTML content into an exe, they don't also display content from the Internet. (Or they've used a separate browser object.) That doesn't mean someone won't, but it just hasn't come up until now so it's not covered in the help file.

You're preachin to the choir with that one. Leave it to me to push the envelope or find the weird sh!tizms in any software.

It's hard enough to write help documentation for my own programs, but I used to work for large companies where my job was to write massive documentation on their systems. It's a real booger to try and cover all events. BANG! gray matter all over the wall.

Just prefix files names with "neobook-ie:".

Aha! That's what I was looking for originally. I tried using:

Code: Select all
BrowserExecScript "WebBrowser1" "window.location = '[Embedded]Help_Contents.html';" "JScript"

.or

BrowserGoto "[Embedded][thisHelpFile]"

.or

BrowserGoto "[Embedded]Help_Contents.html"

... but none of them worked.

Thanks for the pointer. Keep up the great work and support. Awesome!
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest