I don't know why the browser does not work consistently in the following codes. When I navigate to some links after a search on google.com, sometimes the browser becomes invisible. Please help.
(the codes should be in a card script section; the card needs an Image control named Image1)
Code: Select all
local tBrowserID
on openCard
browserOn
end openCard
on closeCard
browserOff
end closeCard
on browserOn
put revBrowserOpen((the windowId of this stack), "http://google.com") into tBrowserID
revBrowserSet tBrowserID, "showborder", true
revBrowserSet tBrowserID, "rect", the rect of image "Image1"
end browserOn
on browserBeforeNavigate tBrowserID, pURL
global browserCancel
if "google.com" is not in pURL then
answer warning "Cannot navigate away from google.com."
put true into browserCancel
end if
end browserBeforeNavigate
on browserOff
if tBrowserID is an integer then
revBrowserClose tBrowserID
end if
put empty into tBrowserID
end browserOff