Webpages

Moderators: LCNeil, heatherlaine, kevinmiller, elanorb

Post Reply
marcelloe
Posts: 140
Joined: Thu Oct 17, 2013 2:26 pm

Webpages

Post by marcelloe » Mon Mar 17, 2014 8:34 pm

How do I display a webpage in a field? I have tried the following and it puts the HTML code into the field.

Code: Select all

Put URL "http://www.google.com" into field "field"

charms
Posts: 122
Joined: Mon Feb 10, 2014 6:21 pm
Location: Singapore
Contact:

Re: Webpages

Post by charms » Tue Mar 18, 2014 1:43 am

If you want to display the contents of a web page then I guess you'll have to take a browser object rather then a text field. I think this can only be done through code. There doesn't seem to be a dragable object in LiveCode. There is a dragable object however in the newest Mobgui for the mobile dependent browser. Look for revBrowser in the Dictionary. Be aware that for mobile you'll need to use the mobile dependent browser. So you need to use following code for example:

Code: Select all

if the environment is "mobile" then
# use the mobile browser commands
else
# use the revBrowser commands
end if
This is how I'm doing it. But I'm no expert yet. Maybe a LiveCode Professional can provide additional options.

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Webpages

Post by LCNeil » Tue Mar 18, 2014 1:58 pm

Hi Mark et al,

It is not possible to place a webpage into a field and as charms has mentioned, you will need to use either a native mobile browser control or revBrowser on desktop-

There is a great tutorial on how to integrate a native mobile browser here-

http://lessons.runrev.com/s/lessons/m/4 ... er-control

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

marcelloe
Posts: 140
Joined: Thu Oct 17, 2013 2:26 pm

Re: Webpages

Post by marcelloe » Tue Mar 18, 2014 7:00 pm

I have read the lesson. It is talking about creating a browser to use. I want a specific webpage when the card is opened and be able to display that in a window for say. This is for mobile.

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Webpages

Post by LCNeil » Wed Mar 19, 2014 2:10 pm

Hi Mark,

You will need to create a browser control if you wish to display a webpage within your card. You should be able to create and set the browser control within the openCard handler so it executes when a specific card is opened.

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

charms
Posts: 122
Joined: Mon Feb 10, 2014 6:21 pm
Location: Singapore
Contact:

Re: Webpages

Post by charms » Sun Mar 23, 2014 8:30 pm

Hi Mark,

Here is an example from my code. Hope it helps.

Code: Select all

local tBrowser -- browser object
local tMobileBrowser -- mobile browser object

on startBrowser
   if the environment is "mobile" then
      mobileControlCreate "browser" -- creates a new browser window on current card
      put the result into tMobileBrowser
      mobileControlSet tMobileBrowser, "rect", the rect of this card
      mobileControlSet tMobileBrowser, "visible", "true"
      mobileControlSet tMobileBrowser, "url", tData[tPos]["location"]
   else 
      put revBrowserOpen(the windowId of this stack, tData[tPos]["location"]) into tBrowser
      if tBrowser is not an integer then
         answer "Failed to open browser"
      end if
      revBrowserSet tBrowser, "showborder", true
      revBrowserSet tBrowser, "visible", true
      revBrowserSet tBrowser, "rect", rect of this card
   end if
end startBrowser

on stopBrowser
   if the environment is "mobile" then
      mobileControlDelete tMobileBrowser
   else
      if tBrowser is not empty then
         revBrowserClose tBrowser
      end if
   end if
end stopBrowser

on resizeBrowser
   if the environment is "mobile" then
      mobileControlSet tMobileBrowser, "rect", the rect of this card
   else
      if tBrowser is not empty then
         revBrowserSet tBrowser, "rect", rect of this card
      end if
   end if
end resizeBrowser

Post Reply

Return to “idea2app and Coding School”