Page 1 of 1
revBrowserCallScript
Posted: Wed Mar 09, 2011 1:24 pm
by Dixie
Hi...
Has anyone got any experience of using 'revBrowserCallScript' ... all I can get out of it is :-
Code: Select all
global browserID
on mouseUp
get revBrowserCallScript (browserID, "codeAddress" )
put the result
end mouseUp
execution error at line n/a () near "-[WebUndefined cStringUsingEncoding:]: unrecognized selector sent to instance 0x17064190"
I would really like to be able to call a javaScript function in the revBrowser. Any help appreciated.
thanks...
Dixie
Re: revBrowserCallScript
Posted: Mon Mar 14, 2011 3:42 pm
by Mark
Hi Dixie,
You need to replace your parameter "codeAddress" with valid JavaScript syntax, for example "codeAddress();".
Best,
Mark
Re: revBrowserCallScript
Posted: Wed Mar 16, 2011 6:59 pm
by Dixie
Mark...
Thanks for the reply... unfortunately, using your suggestion does not work
get revBrowserCallScript (browserID, "codeAddress();" )
be well,
Dixie
Re: revBrowserCallScript
Posted: Thu Feb 19, 2015 2:53 pm
by GSPearson
Any update to this with code samples. I am using LC 7.0 and the project I am working on I would love to do this to turn on and off a map layer that has school buildings locations within it. When I call this the error I get is
Button :Button": execution error at line /na/ (External; handler: exception) neqar "unknown browser if"
Code: Select all
global gBrowserID
on mouseUp
get revBrowserCallScript(gBrowserID, DisplayAlert(), "Testing from Livecode")
end mouseUp
gBrowserID has an value of 11011524
The card that draws the map defines this value that gBrowserId has and within the button I get the same value for gBrowserID
Any Ideas?
Re: revBrowserCallScript
Posted: Thu Feb 19, 2015 3:22 pm
by Mark
Hi,
Is DisplayAlert() a JavaScript function? Try putting it in quotes.
Kind regards,
Mark
Re: revBrowserCallScript
Posted: Thu Feb 19, 2015 7:36 pm
by GSPearson
Yes on the page within the web server has
Code: Select all
<script type="text/javascript">
function DisplayAlert(txt) {
alert(txt);
}
</script>
When I put the DisplayAlert() within quotes, The error message I get is
"unknown browser id"
However in my variables tab of editor, gBrowserID has a value of 5441464. This button which calls the function through revBrowserCallScript and the gBrowserID is set within the openCard script.
Re: revBrowserCallScript
Posted: Thu Feb 19, 2015 7:56 pm
by Mark
Hi,
5441464 is a very high number for a browser ID created with revBrowser. Are you sure that gBrowseID has been declared as a global variable? Can you check where this number comes from exactly?
Kind regards,
Mark
Re: revBrowserCallScript
Posted: Thu Feb 19, 2015 8:19 pm
by GSPearson
On the Map Card here is the script
Code: Select all
global gScreenSize, gScreenCenterLoc, gResizeStackHorizontal, gResizeStackVertical, gDeviceHasNetworkConnection, gDeviceHasInternetConnection
global gServerName, gMainApplicationArchiveFilename, gMainApplicationFilename, gSplashAppVersion, gApplicationPrefsDir, gProgramAppUpdateArray
global gMainAppDownload, gMainAppExtracted, gOrgAvailableMarketsArray, gOrgAvailableMarketTowersArray
global gAreaBTALatitude, gAreaBTALongitude, gAreaCallSign, gAreaCity, gAreaState
global gDecLatitude, gDecLongitude, gBrowserID
on openCard
local tMapURL
put "Viewing Map for: " into field "Map Heading" on me
put gAreaCity & "," && gAreaState && "(" & gAreaCallSign & ")" after field "Map Heading"
-- If any open browsers lets close them
resetCard
-- Create the Browser Object
lock messages
put the windowID of this stack into gBrowserID
unlock messages
if gBrowserId is not an integer then
answer "Failed to open browser"
else
-- This links or sets the rec area of the browser to the rec area of the BrowserBackground
put gServerName & "/LivecodeApps/EBSLicenseMapApp/MapDisplay.cfm?" into tMapURL
put "CLat=" & gDecLatitude & "&" after tMapURL
put "CLon=" & gDecLongitude & "&" after tMapURL
put "MarkerTitle=" & gAreaCallSign after tMapURL
put revBrowserOpen(gBrowserID, tMapURL) into tBrowserID
revBrowserSet tBrowserID, "rect", the rect of image "BrowserArea"
-- revBrowserSet lBrowserID, "url", tMapURL
end if
end openCard
on preOpenCard
end preOpenCard
on resetCard
-- Clears the browser from the screen and memory
closeBrowsers
-- Set top Full Width
set the rect of image "BrowserArea" to 14,28,1014,702
end resetCard
on closeBrowsers
-- Close all browser in memory
repeat for each item gBrowserID in revBrowserInstances()
revBrowserClose gBrowserID
end repeat
end closeBrowsers
on closeCard
closeBrowsers
end closeCard
Then on the button which is on the same card the code is
Code: Select all
global gScreenSize, gScreenCenterLoc, gResizeStackHorizontal, gResizeStackVertical, gDeviceHasNetworkConnection, gDeviceHasInternetConnection
global gServerName, gMainApplicationArchiveFilename, gMainApplicationFilename, gSplashAppVersion, gApplicationPrefsDir, gProgramAppUpdateArray
global gMainAppDownload, gMainAppExtracted, gOrgAvailableMarketsArray, gOrgAvailableMarketTowersArray
global gAreaBTALatitude, gAreaBTALongitude, gAreaCallSign, gAreaCity, gAreaState
global gDecLatitude, gDecLongitude, gBrowserID
on mouseUp
get revBrowserCallScript(gBrowserID, "DisplayAlert()", "Testing from Livecode")
put the result into it
end mouseUp
Re: revBrowserCallScript
Posted: Thu Feb 19, 2015 8:25 pm
by GSPearson
I changed tBrowserId into gtBrowserID and on the
Code: Select all
get revBrowserCallScript(gtBrowserID, "DisplayAlert()", "Testing from Livecode")
the error is:
button "Button": execution error at line n/a (External handler: exception) near "error in script"
Re: revBrowserCallScript
Posted: Thu Feb 19, 2015 8:41 pm
by Mark
Hi,
gBrowserID is not the windowID. It is the output from revBrowserOpen.
Code: Select all
put revBrowserOpen(the windowID of this stack,"") into gBrowserID
Now, gBrowserID should start at 1 and increase by 1 every time you create a new browser instance.
Kind regards,
Mark
Re: revBrowserCallScript
Posted: Thu Feb 19, 2015 8:56 pm
by GSPearson
In tracing the code, I got gBrowserID which starts with 1 and does increase by 1 each time a new map is displayed within the image rectangle.
I changed the Javascript to not use a parameter and it does work.
Code: Select all
on mouseUp
get revBrowserCallScript(gBrowserID, "DisplayAlert")
put the result into it
end mouseUp
Now to try and figure out the parameters of the javascript function