BrowserControl with scriptable web console?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Klaus
Posts: 14211
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: BrowserControl with scriptable web console?

Post by Klaus » Fri Feb 21, 2014 5:17 pm

HI Esso,

well, sometimes it takes some time until I "get" it 8)

But once I got it, he he he! :D


Best

Klaus

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: BrowserControl with scriptable web console?

Post by EssoAir » Fri Feb 21, 2014 10:20 pm

Klaus wrote:HI Esso,

well, sometimes it takes some time until I "get" it 8)

But once I got it, he he he! :D


Best

Klaus
What is sBrowserId?

the example from the doc is
get revBrowserExecuteScript(sBrowserId, "alert('This is a debugging message');"
get revBrowserExecuteScript(sBrowserId, the text of field "JavaScript" of me)
sorry is this is obvious but I'm not that good with livecode. I'm more of the web-development type

Klaus
Posts: 14211
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: BrowserControl with scriptable web console?

Post by Klaus » Sat Feb 22, 2014 1:11 pm

Hi Esso,

when you open a (new instance of the) browser control, which is in fact an OVERLAY on top of your stack,
you will get an ID, that you can later use to manage that namely browser instance:

Code: Select all

...
## Make this variable LOCAL or GLOBAL, depending on where you put all your revBrwoser..." scripts:
global sBrowserID

## 1. You need to supply a window ID, where the browser instance will "stick" to:
put the windowid of this stack into tWID

## 2. Open instance and store its ID for later use!
put revBrowserOpen(tWID,"http://www.server.com/page.html") into sBrowserID

## 3. Check for possible errors, ID MUST be an integer on success:
if sBrowserID is not an integer then
  answer "Problems openeing browser:" && sBrowserID
  exit to top
end if

## 4.
## Now you need to set some properties of the browser to position the window and SHOW it:
## I ususally use a HIDDEN graphic as a placeholder for the RECT of my browser
put the rect of grc "the hidden placeholder for the browser" into tRect
revBrowserSet sBrowserID, "rect", tRect
revBrowserSet sBrowserID, "visible", TRUE
### etc. check all "revBrowser..." commands and functions in the dictionary.
...
That are the basic commands to open a browserinstance on top of the current card.
And DONT forget to add a button somewhere to close the browser!
...
revBrowserClose sBrowserID
...

Best

Klaus

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: BrowserControl with scriptable web console?

Post by EssoAir » Sat Feb 22, 2014 3:25 pm

Thank you! I got it working but sadly now it won't run my JS even though it works perfectly in Chrome, Safari and Firefox :(

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: BrowserControl with scriptable web console?

Post by EssoAir » Wed Feb 26, 2014 2:11 am

Klaus wrote:Hi Esso,

when you open a (new instance of the) browser control, which is in fact an OVERLAY on top of your stack,
you will get an ID, that you can later use to manage that namely browser instance:

Code: Select all

...
## Make this variable LOCAL or GLOBAL, depending on where you put all your revBrwoser..." scripts:
global sBrowserID

## 1. You need to supply a window ID, where the browser instance will "stick" to:
put the windowid of this stack into tWID

## 2. Open instance and store its ID for later use!
put revBrowserOpen(tWID,"http://www.server.com/page.html") into sBrowserID

## 3. Check for possible errors, ID MUST be an integer on success:
if sBrowserID is not an integer then
  answer "Problems openeing browser:" && sBrowserID
  exit to top
end if

## 4.
## Now you need to set some properties of the browser to position the window and SHOW it:
## I ususally use a HIDDEN graphic as a placeholder for the RECT of my browser
put the rect of grc "the hidden placeholder for the browser" into tRect
revBrowserSet sBrowserID, "rect", tRect
revBrowserSet sBrowserID, "visible", TRUE
### etc. check all "revBrowser..." commands and functions in the dictionary.
...
That are the basic commands to open a browserinstance on top of the current card.
And DONT forget to add a button somewhere to close the browser!
...
revBrowserClose sBrowserID
...

Best

Klaus
I made a feature request, but its a really simple one that should be quite easy to implement but im afraid that it might get overlooked. Klaus, can you add the ability to use browserDocumentComplete on mobile? It works great on desktops but its not available on mobile.

Thanks!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7394
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: BrowserControl with scriptable web console?

Post by jacque » Wed Feb 26, 2014 7:31 am

EssoAir wrote: I made a feature request, but its a really simple one that should be quite easy to implement but im afraid that it might get overlooked. Klaus, can you add the ability to use browserDocumentComplete on mobile? It works great on desktops but its not available on mobile.
Have you looked at browserFinishedLoading?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: BrowserControl with scriptable web console?

Post by EssoAir » Wed Feb 26, 2014 2:28 pm

jacque wrote:
EssoAir wrote: I made a feature request, but its a really simple one that should be quite easy to implement but im afraid that it might get overlooked. Klaus, can you add the ability to use browserDocumentComplete on mobile? It works great on desktops but its not available on mobile.
Have you looked at browserFinishedLoading?
THANK YOU! I completely missed that

Klaus
Posts: 14211
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: BrowserControl with scriptable web console?

Post by Klaus » Wed Feb 26, 2014 2:39 pm

Hi Esso,
EssoAir wrote:Klaus, can you add the ability to use browserDocumentComplete on mobile?
I wish I could! It may surprise you, but I am just a user of Livecode and not employed at or related to RunRev in any way. 8)


Best

Klaus

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: BrowserControl with scriptable web console?

Post by EssoAir » Wed Feb 26, 2014 3:38 pm

Klaus wrote:Hi Esso,
EssoAir wrote:Klaus, can you add the ability to use browserDocumentComplete on mobile?
I wish I could! It may surprise you, but I am just a user of Livecode and not employed at or related to RunRev in any way. 8)


Best

Klaus
Well since you're good with livecode, can yo help me figure out how to use " mobileControlCreate 'browser' " on a desktop?

Klaus
Posts: 14211
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: BrowserControl with scriptable web console?

Post by Klaus » Wed Feb 26, 2014 4:07 pm

Hi Esso,

see my script above, does exactly what you want! :D
"revBrowser" is the "desktop equivalent" for -> mobilecontrolcreate "browser"...


Best

Klaus

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: BrowserControl with scriptable web console?

Post by EssoAir » Wed Feb 26, 2014 4:17 pm

Klaus wrote:Hi Esso,

see my script above, does exactly what you want! :D
"revBrowser" is the "desktop equivalent" for -> mobilecontrolcreate "browser"...


Best

Klaus
do I have to make different .livecode files for desktop and mobile?

Klaus
Posts: 14211
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: BrowserControl with scriptable web console?

Post by Klaus » Wed Feb 26, 2014 4:25 pm

HI Ess,.
EssoAir wrote:do I have to make different .livecode files for desktop and mobile?
not neccessarily!

You can check "the environment" and act accordingly, something like this:

Code: Select all

on opencard
  ## or whenever

   ## We are on iOS or Android
  if the environment = "mobile" then
     mobilecontrolcreate "browser"...
     ## More mobile stuff...

  else
     ## Desktop:
     put revBrowseropen(...)
    ## More desktop stuff...
  end if
end opencard
You get the picture :D

And maybe take a look at this stack:
http://livecodeshare.runrev.com/stack/7 ... er-Sampler

Best

Klaus

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: BrowserControl with scriptable web console?

Post by EssoAir » Wed Feb 26, 2014 6:30 pm

Klaus wrote:HI Ess,.
EssoAir wrote:do I have to make different .livecode files for desktop and mobile?
not neccessarily!

You can check "the environment" and act accordingly, something like this:

Code: Select all

on opencard
  ## or whenever

   ## We are on iOS or Android
  if the environment = "mobile" then
     mobilecontrolcreate "browser"...
     ## More mobile stuff...

  else
     ## Desktop:
     put revBrowseropen(...)
    ## More desktop stuff...
  end if
end opencard
You get the picture :D

And maybe take a look at this stack:
http://livecodeshare.runrev.com/stack/7 ... er-Sampler

Best

Klaus
Wow lots of code! Ill take a closer look when i get home. I cant run LiveCode on my iPad so i cant do it at school :/

Post Reply