In order to use the web page navigator, it is first necessary to create an instance of Browser. It is necessary to keep a handle or reference to the instance we created:
# declare the local id of the browser we are creating
local sBrowserId
Once we have a place to store the instance of Browser we can implement the code that initializes Browser and configure its default settings:
# when the card is opened make sure that default settings are configured
on preOpenCard
# quit if we are not on a mobile device
if the environment is not "mobile" then
exit preOpenCard
end if
# create the browser
mobileControlCreate "browser"
put the result into sBrowserId
# set up the basic defaults
mobileControlSet sBrowserId, "rect", the rect of group "Browser"
mobileControlSet sBrowserId, "visible", "true"
mobileControlSet sBrowserId, "url", "http://www.google.com"
end preOpenCard
On terminating the web page navigator, it is necessary to destroy the Browser instance:
on closeCard
if the environment is not "mobile" then
exit closeCard
end if
# destroy the browser we created
mobileControlDelete sBrowserId
end closeCard