BYU Home pageBRIGHAM YOUNG UNIVERSITY
  Humanities Technology and Research Support Center
Back     CHum Revolution Gateway

CHum 310
In-class Demo:
Embedding a Browser in Your Stack

Showing web text and graphics in your stack is all well and good, but there may be times when you just want to show a web page in your stack without worrying about whether or not Revolution can display everything properly. Revolution includes the revBrowser library that allows you to do just that. RevBrowser uses existing web browser engines on Mac (Safari) and Windows (Internet Explorer) to create a browser object that is displayed directly on a card in your stack.

Here is a screenshot of a stack with an embedded browser:

Embedded browser in a stack.

Although there are many ways that an embedded browser may be displayed and configured, the basic process for creating one is quite straightforward. These handlers in, say, the card script, allow you to create a basic browser object:

local browserid # declare browserID as script local variable so 
                # it can be used in both handlers 

on openBrowser
  # save the windowid in a variable for future reference
  put the windowid of this stack into tID
  
  # When you open a browser with the revBrowserOpen function,
  #  a unique browser ID number is generated. Thereafter
  #  whenever you do something with that browser you must 
  #  supply the browser ID, so save it in a variable.
  put revBrowserOpen(tID,fld "urlFld") into browserid
  
  # This is how to change properties of a browser object.
  # The syntax is
  #    revBrowserSet browser ID, property name, property setting
  revBrowserSet browserid,"rect",the rect of grc "browserOutline"
  revBrowserSet browserid,"showBorder","true"
end openBrowser

on closeBrowser
  # closing a browser is straightforward:
  revbrowserclose browserid
end closeBrowser 

All that remains now is to call openBrowser in the Open button. When you are finished with the browser, call closeBrowser. You could do this in a button or in a closeCard handler.

For more information you can take a look at a revBrowser tutorial stack produced by Runtime Revolution. It can be found in the Resources folder on the CHum 310 file server. Or simply enter this in the Revolution message box:

go stack URL "http://chum310.byu.edu/Resources/revBrowser Tutorial.rev"

Happy rev-surfing!


Back     CHum Revolution Gateway
Maintained by Devin Asay.
Copyright © 2005 Brigham Young University