Page 1 of 1
Can't display webpage from livecode Mac application
Posted: Mon Oct 17, 2022 10:11 pm
by Jojo60
Hi, who can help me getting to work a code like this on a Mac. In Windows it works fine. But not on my MacBook. Thanks. Kind regards Johan
on browserOpen
put "
http://www......." into sLink
put revBrowserOpen(the windowId of this stack, sLink) into sBrowserID
revBrowserSet sBrowserID, "rect" , the rect of graphic "browsersq"
revBrowserSet sBrowserID, "scrollbars", false
end browserOpen
on mouseUp pMouseButton
browserOpen
end mouseUp
Re: Can't display webpage from livecode Mac application
Posted: Mon Oct 17, 2022 11:58 pm
by stam
I just tried the example in the documentation:
Code: Select all
local tBrowserId
put revBrowserOpen(the windowId \
of this stack, "http://www.livecode.com" ) into tBrowserId
if tBrowserId is not an integer then
answer "Failed to open browser"
end if
This fails to open a safari window browser on Mac... i have no prior experience with this command, if this s not expected behaviour then a bug report is probably in order?
Re: Can't display webpage from livecode Mac application
Posted: Tue Oct 18, 2022 7:34 am
by SparkOut
Without knowing anything and not able to check the problem or the code, first guess is that the url needs to be https:// unless you can instruct the browser instance to disable secure site requirements.
Re: Can't display webpage from livecode Mac application
Posted: Tue Oct 18, 2022 7:52 am
by stam
SparkOut wrote: ↑Tue Oct 18, 2022 7:34 am
Without knowing anything and not able to check the problem or the code, first guess is that the url needs to be https:// unless you can instruct the browser instance to disable secure site requirements.
I can’t check right now but seems unlikely. As far as I can tell from the documentation, this is meant open a new window in Safari and then navigate to the URL, however safari is never even launched - so it doesn’t appear to be a URL problem.
But I will check when I get a chance…
Re: Can't display webpage from livecode Mac application
Posted: Tue Oct 18, 2022 9:02 am
by bn
Hi Jojo,
I tried your code on a Mac
Code: Select all
local sBrowserID
on browserOpen
put "https://www.google.com" into sLink
put revBrowserOpen(the windowId of this stack, sLink) into sBrowserID
revBrowserSet sBrowserID, "rect" , the rect of graphic "browsersq"
revBrowserSet sBrowserID, "scrollbars", false
end browserOpen
on mouseUp pMouseButton
browserOpen
end mouseUp
I tried this after having tried a couple of times to create successfully a browser with slight variations of your code and then your code failed, debugging failed also.
Closing Livecode and reopening it then your code (as above) worked.
What I gather from this is that LC does not like too many browser instances at the same time.
Could you try this in a freshly started LC?
Why don't you use a Browser Widget?
Disclaimer:
I have hardly any experience using a browser in LC.
Kind regards
Bernd
Re: Can't display webpage from livecode Mac application
Posted: Tue Oct 18, 2022 9:03 am
by bn
@Stam
You have to set the rect of the browser to make it visible.
Kind regards
Bernd
Re: Can't display webpage from livecode Mac application
Posted: Tue Oct 18, 2022 9:25 am
by Klaus
What are the advantages of using revbrowseropen vs the browser widget?
Re: Can't display webpage from livecode Mac application
Posted: Tue Oct 18, 2022 10:58 am
by stam
bn wrote: ↑Tue Oct 18, 2022 9:03 am
You have to set the rect of the browser to make it visible.
Kind regards
Bernd
Thanks Bernd (as always!)... I was a bit mystified until i noticed the sentence quite far down, near the end of the documentation:
Dictionary/revBrowserOpen wrote:The default rect of a new browser instance is 0,0,0,0. To change this, set the "rect" property using the revBrowserSet command.
That's a blinder.... Perhaps this needs to be given a position of prominence in the documentation
Also it really didn't do what i'd thought it would do based on how the Dictionary is written (namely launch Safari) but as Klaus points out just creates a browser inside the stack much like the browser widget but without the benefit of being able to manipulate the browser object in the IDE (plus it seems to cause a really annoying flicker on scrolling).
I have to echo Klaus' question:
Klaus wrote: ↑Tue Oct 18, 2022 9:25 am
What are the advantages of using revbrowseropen vs the browser widget?
Re: Can't display webpage from livecode Mac application
Posted: Tue Oct 18, 2022 12:00 pm
by Jojo60
Thank you all already for your help. Sites with https open fine, I see now too. It is about this "key2publish.../portal2/registration" site.
Unfortunately it will use http for a while. So I will try to find out how I can open it and check out your comments. Kind regards Johan