Opening a web page in a card

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ronniebellie
Posts: 28
Joined: Fri Jun 26, 2015 6:17 pm

Opening a web page in a card

Post by ronniebellie » Mon Aug 03, 2015 7:36 pm

How do I tell livecode to open a web page in a card. I don't want any controls on the card, just the web site showing and a return to home card button which I will make at the bottom.

What is the code for my button that will open the card and display the web page. Below is the page I want to open in my app. It's using the Bootstrap3 theme which is optimized for mobile.

http://spokaneesl.com/presenters/

Thanks,

Ron

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Opening a web page in a card

Post by Klaus » Mon Aug 03, 2015 7:55 pm


ronniebellie
Posts: 28
Joined: Fri Jun 26, 2015 6:17 pm

Re: Opening a web page in a card

Post by ronniebellie » Mon Aug 03, 2015 8:33 pm

Thanks. That made sense and I was able to do it. How do I resize the "browserPlaceholder" the graphic object? Once it's populated with the web page, it no longer has handles on it to be able to resize on the stack.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Opening a web page in a card

Post by Klaus » Tue Aug 04, 2015 12:08 pm

Hi Ronnie,

yes, this is how these externals like the BROWSER object work!
They put an OVERLAY on top of all controls, which is not really part of the stack.

You will need to change the rect of the browser by script! We cannot resize a browser manually!
Resizing the "reference" graphic will still require that you set the browsers rect by script!

In fact the "reference" object is really not necessary, it just makes the whole thing more "visual".
You can of course supply a rect directly to the browser like this, which will cover the complete card but leave
a 30 pixel area at the bottom of the card:
...
put "0,0," & the width of this stack & "," & the height of this stack - 30 into tRect
revBrowserSet tBrowserID, "rect", tRect
...

Best

Klaus

ronniebellie
Posts: 28
Joined: Fri Jun 26, 2015 6:17 pm

Re: Opening a web page in a card

Post by ronniebellie » Tue Aug 04, 2015 7:25 pm

Okay. I see. I've done this and put a button at the bottom of the browser instance card to return to the main card. However, the browser instance is being applied to the home page too overlaying it.
How do I end the browser instance when I go to another card?

Here's the code to return to my main card.
on mouseUp
go to card 1
end mouseUp

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Opening a web page in a card

Post by Klaus » Tue Aug 04, 2015 8:24 pm

Hi Ron,

I ususally put this into the card script:

Code: Select all

on closecard
  revbrowserclose sBrwoserID
end closecard
So the browser will close automatically when leaving the card.


Best

Klaus

ronniebellie
Posts: 28
Joined: Fri Jun 26, 2015 6:17 pm

Re: Opening a web page in a card

Post by ronniebellie » Thu Aug 06, 2015 6:39 pm

Hi Klaus,

Something is still not working with this. On my main stack page I have a button that opens another card with a browser instance.

on mouseUp
go to card "Presenter info card"
put revBrowserOpenCef(the windowId of this stack, "http://spokaneesl.com/presenters/index.html") into tBrowserID
revBrowserSet tBrowserID, "rect", the rect of field "browserPlaceholder"
end mouseUp

This above is all working. The card "Presenter info card" is populated with the web site that I want. At the bottom of the card, there is a button which says "Return to home card."
on mouseUp
go to card 1
end mouseUp

In the card script titled "Presenter info card", I have this code.

on closecard
  revbrowserclose sBrowserID
end closecard

But when I click the button to leave the card and return to the home card, I get an unknown browser id message.

What am I doing wrong?

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Opening a web page in a card

Post by Klaus » Thu Aug 06, 2015 6:55 pm

Hi Ronnie,
ronniebellie wrote:What am I doing wrong?
you are using MY example variable name :D

Code: Select all

...
## My example: sBrowserID
## revbrowserclose sBrowserID

## Your actual variable name: tBrowserID
revbrowserclose tBrowserID
...
Best

Klaus

ronniebellie
Posts: 28
Joined: Fri Jun 26, 2015 6:17 pm

Re: Opening a web page in a card

Post by ronniebellie » Thu May 05, 2016 12:10 am

This code I thought used to work in v. 7x to open a web page on a card, but in V.8 it doesn't

Do you know why?

global tBrowserID

on mouseUp
go to card "placeholder"
put revBrowserOpenCef(the windowId of this stack, "http://spokaneesl.com/exhibitors/index.html") into tBrowserID
put "0,0," & the width of this stack & "," & the height of this stack - 30 into tRect
revBrowserSet tBrowserID, "rect", tRect
end mouseUp

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Opening a web page in a card

Post by Klaus » Thu May 05, 2016 5:28 pm

Hi Ronnie,

is this on a Mac?
From the "Release Notes" of LC 8:
##################################################
Removal of CEF support from OS X version of revBrowser external and 8.0 browser widget. (8.0.0-dp-16)
Due to the lack of support for 32-bit Chromium on Mac OS X (and thus Chromium Embedded Framework)
we will no longer be using libCEF to provide an embedded browser on OSX, either with the revBrowser external, or the new browser widget.

If you currently use revBrowser and the revBrowserOpenCEF command to create the browser, this will no longer function.

We advise you to switch to using revBrowserOpen when your application is running on OSX.
The browser widget will continue to function as before, as the implementation has already been changed to use the OSX WebView class by default.
##########################################
Get used to the new browser widget, very nice! :D

Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”