Page 1 of 1

Can't open local HTML file with RevBrowser

Posted: Tue Nov 11, 2014 3:09 am
by annettes
I am trying to open a local HTML file in RevBrowser, in order to display a Youtube video. If I load the HTML file up to a website and access using the http prefix it works fine. But when I try to access it as a local file, stored in the same directory as the stack, Livecode hangs and the browser is not displayed. I am working on Windows 7 in the development environment and using Livecode 6.6.2.

This is the code I am using for the card containing the browser:

Code: Select all

on preOpenCard
   openBrowser
end preOpenCard

on closeCard
   closeBrowser
end closeCard

local sBrowserId, tPath

on openBrowser
   put the windowid of this stack into tWinID
   set the itemdel to "/"
   put the effective filename of stack "Food Chain" into tPath
   delete last item of tPath
   put "/dissolvedOxygen.html" after tPath
   put "file://" before tPath
  
  -- Open the browser, using the windowId and initial url
  put revBrowserOpen(tWinID,tPath) into sBrowserId

  -- Set some basic properties for the browser
  revBrowserSet sBrowserId, "showborder",false
  revBrowserSet sBrowserId, "scrollbars",false
  revBrowserSet sBrowserId, "rect", (250,220,900,600)
end openBrowser

on closeBrowser
  revBrowserClose sBrowserId
end closeBrowser
I have tried using "file:/", "file://" and "file:///" but nothing works. I have displayed the pathname of the file using answer and it is correct. There are no spaces in the pathname. What am I doing wrong?
Thanks.

Re: Can't open local HTML file with RevBrowser

Posted: Tue Nov 11, 2014 3:57 am
by [-hh]
You could try this, it works for me.

Code: Select all

...
  put "file:" before tPath ## <----
  -- Open the browser, using the windowId and initial url
  put revBrowserOpen(tWinID,tPath) into sBrowserId
  -- Set some basic properties for the browser
  revBrowserSet sBrowserId, "showborder",false
  revBrowserSet sBrowserId, "scrollbars",false
  revBrowserSet sBrowserId, "rect", (250,220,900,600)
  revBrowserRedraw sBrowserId ## <----
...

Re: Can't open local HTML file with RevBrowser

Posted: Fri Nov 14, 2014 2:36 pm
by Klaus
Hi annettes,

1. welcome to the forum! :D

2. Maybe you have some SPACES in your pathname? The browser does not like that!

Do this:

Code: Select all

on openBrowser
   put the windowid of this stack into tWinID
   set the itemdel to "/"
   put the effective filename of stack "Food Chain" into tPath
   delete last item of tPath
   put "/dissolvedOxygen.html" after tPath
   put "file://" before tPath
  
  ## The trick:
  replace SPACE with "%20" in tPath
...
At least worth a try :D


Best

Klaus

Re: Can't open local HTML file with RevBrowser

Posted: Fri Nov 14, 2014 4:53 pm
by [-hh]
Hi 'anettes'.

I saw too late that you are on Win. It's presumably the missing partition name ("C" or "D" or whatever in your path). See below.
Also I prefer to use "file:" as prefix. Please, test both "file: and "file://".

Hi Klaus,
she has no space in her path (she wrote).
And using "file://" sometimes failed for me (for complicated file locations on external drives), but never "file:".

The following is tested on LC 5.5./6.6.5/6.7/7.0 and Mac+Win for a local file.

Code: Select all

# on Mac
local baseaddress="/Users/hh/Documents/"
# on Win
local baseaddress "C:/Users/hh/Documents/" --> watch the leading "C:"
#
# and then, on both platforms the same:
#
put revBrowserOpen(tWinID) into sBrowserId
# set here rect, scrollbars etc., then:
revBrowserSet sBrowserId, "url", ("file:" & baseaddress & "test.html")
revBrowserRedraw sBrowserId
With LC 6.7 and later this works also for revBrowserOpenCEF
(NOT on Mac for a local PDF, YES on Win for a local PDF).

On which version of LC and platform/OS did you run your script (could be interesting for tests of differences between revBrowserOpen and revBrowserOpenCEF)?

Hermann

Re: Can't open local HTML file with RevBrowser

Posted: Fri Nov 14, 2014 5:19 pm
by Klaus
[-hh] wrote:Hi Klaus,
she has no space in her path (she wrote).
Oh, yes, sorry, overlooked this one...

Re: Can't open local HTML file with RevBrowser

Posted: Tue Nov 18, 2014 12:23 am
by annettes
Hi Everyone,
Thanks for your replies. I tried what you suggested Hermann. The result is that now nothing is displayed. Previsouly when it couldn't find the file, the revBrowser would appear and there would be a message in it saying it couldn't find the file. Now I just get an empty space. I tried adding a border and scrollbars to the browser so that I would know if it was there or not, but these do not appear, so it seems like the browser is not being drawn.

The "C:/" was always present at the start of the path name. I display it in an answer box to check.

This is my code

Code: Select all

   put the windowid of this stack into tWinID
   set the itemdel to "/"
   put the effective filename of stack "Food Chain" into tPath
   delete last item of tPath
   answer question tPath with "OK"
  
  put revBrowserOpen(tWinID) into sBrowserId
  -- Set some basic properties for the browser
  revBrowserSet sBrowserId, "showborder",true
  revBrowserSet sBrowserId, "scrollbars",true
  revBrowserSet sBrowserId, "rect", (250,220,900,600)
  
 revBrowserSet sBrowserId, "url", ("file:" & tPath & "/dissolvedOxygen.html")
 revBrowserRedraw sBrowserId
Do you have any other suggestions?
Thanks,
Annette

Re: Can't open local HTML file with RevBrowser

Posted: Tue Nov 18, 2014 3:15 am
by [-hh]
Hi, could you please try a newer version (6.7.1-rc2 is very good), downloadable here:
http://downloads.livecode.com/livecode/
May be this is an old problem of 6.6.2.?
Perhaps Klaus knows more, he's a knowledgeable fox, I'm rather a greenhorn ...

Re: Can't open local HTML file with RevBrowser

Posted: Tue Nov 18, 2014 2:03 pm
by Klaus
Hi all,

although the DEFAULT value for VISIBLE is supposed to be TRUE, adding this is worth a try:
...
revBrowserSet sBrowserId, "visible",true
...

Best

Klaus

Re: Can't open local HTML file with RevBrowser

Posted: Thu Nov 20, 2014 6:48 am
by annettes
Hi Klaus and Hermann,
When I opened the livecode file again (in 6.6.2 initially), the border and scrollbars were visible, without having to set the visible property. Maybe I hadn't saved it properly last time. But still the browser was completely empty. However, it does take a long time before I can do anything else, so there is some processing going on. Then I tried it in 6.6.7 STABLE, but the same thing happened. I don't know why.
Thanks for your suggestions.
Annette

Re: Can't open local HTML file with RevBrowser

Posted: Thu Nov 20, 2014 8:38 am
by SparkOut
Does it work if you try to open a local html file with just some "hello world" text?
I wonder if there is an issue with trying to have the local file stream in from YouTube.

Re: Can't open local HTML file with RevBrowser

Posted: Thu Nov 20, 2014 10:40 pm
by [-hh]
Hi all,

we are keen to solve your problem, because LC browser works usually fine.
Today I had also a display problem and tried the following:

Opened the browser demo stack of LC (Toolbar > Resources > Internet > Browser Sampler) and dragged the file to the browser window (not to the addressbar, to the display rectangle itself). It worked (and I found, that my file had an exotic encoding).

An easy way to test whether the browser is working. Did you already try this with several files?