47
Chapter 6
JavaScript events to and from the Viewer
Prizm Content Connect is built in such a way that it can be truly integrated and embedded
into your application. Events are JavaScript AJAX calls that the Viewer can generate when
certain actions occur. Developers can also send JavaScript AJAX events to the Viewer from
their code and have the Viewer perform certain actions without reloading the whole page.
Sending events to the Viewer
To send events to the viewer, follow these steps:
1. Pass a FlashVar to Viewer.swf to indicate you will be sending events to Viewer
sendViewerEvents=Yes
2. Add the following code to the page where you call Viewer.swf:
<script language="JavaScript">
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function callViewerFunction(str,arg) {
getFlashMovie("Viewer").sendTextToFlash(str,arg);
}
</script>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse"
bordercolor="#111111" width="100%">
<tr>
<td ><a href=javascript:callViewerFunction("SearchResultMoveNext")>Next Search
Result</a></td>
<td ><a href=javascript:callViewerFunction("SearchResultMovePrevious")>Prev Search
Result</a></td>
<td ><a href=javascript:callViewerFunction("SelectText")>SelectText</a></td>
<td ><a href=javascript:callViewerFunction("PrintRange","1,2")>Print Range</a></td>
<td ><a href=javascript:callViewerFunction("getTotalPages",0)>getTotalPages</a></td>
<td ><a href=javascript:callViewerFunction("Previous",0)>Previous</a></td>
<td ><a href=javascript:callViewerFunction("ZoomTo",200)>Zoom Value</a></td>
<td ><a href=javascript:callViewerFunction("ZoomIn",0)>ZoomIn</a></td>
<td ><a href=javascript:callViewerFunction("ZoomOut",0)>ZoomOut</a></td>
<td ><a href=javascript:callViewerFunction("FitWidth",0)>FitWidth</a></td>
<td ><a href=javascript:callViewerFunction("MoveDown",0)>MoveDown</a></td>
<td ><a href=javascript:callViewerFunction("MoveUp",0)>MoveUp</a></td>
<td ><a href=javascript:callViewerFunction("MoveLeft",0)>MoveLeft</a></td>
<td ><a href=javascript:callViewerFunction("MoveRight",0)>MoveRight</a></td>
<td ><a href=javascript:callViewerFunction("RotateTo",-90)>RotateTo</a></td>
<td ><a href=javascript:callViewerFunction("Rotate",0)>Rotate</a></td>
<td ><a href=javascript:callViewerFunction("Print",0)>Print</a></td>
<td ><a href=javascript:callViewerFunction("PrintAll",0)>Print All</a></td>
<td ><a href=javascript:callViewerFunction("MovetoPage","4")>Move to Page 4</a></td>
</tr>
</table>
34