Altova Authentic 2024 Browser Edition

This is an example HTML page with an embedded JavaScript. The sample requires the Authentic Browser Plug-in (CAB file) to be installed on your computer. Note that case-sensitivity might be an issue with some servers, so if there is a problem locating a file, check the casing of filenames and of commands in the code.

 

The code shows:

 

How to access the browser plug-in. Modify the code to refer to your CAB file and the class identifier (CLSID) of your browser plug-in version (trusted or untrusted).

How to load a file into the browser plug-in. Modify the code to refer to your sample document.

Implement buttons for simple cursor positioning.

Implement more complex commands like the sorting of tables.

How to use the SelectionChanged event.

 

Also see The OBJECT Element for details.

 

<html>

 <head>

         <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

         <title>test page For Authentic Browser Plug-in</title>

 

         <SCRIPT LANGUAGE="javascript" For="objPlugIn" EVENT="ControlInitialized">

                 var strSampleRoot = "http://myRoot/myPath/myDocBaseName";

                 objPlugIn.SchemaLoadObject.URL = strSampleRoot + ".xsd";

                 objPlugIn.XMLDataLoadObject.URL = strSampleRoot + ".xml";

                 objPlugIn.DesignDataLoadObject.URL = strSampleRoot + ".sps";

                 objPlugIn.StartEditing();

         </SCRIPT>

 

         <SCRIPT ID="clientEventHandlers" LANGUAGE="javascript">

                 var objCurrentRange = Null;

 

                 Function BtnDocumentBegin() { objPlugIn.AuthenticView.DocumentBegin.Select(); }

                 Function BtnDocumentEnd() { objPlugIn.AuthenticView.DocumentEnd.Select(); }

                 Function BtnWholeDocument() { objPlugIn.AuthenticView.WholeDocument.Select(); }

                 Function BtnSelectNextWord() { objPlugIn.AuthenticView.Selection.SelectNext(1).Select(); }

                 Function BtnSortDepartmentOnClick()

                 {

                         var objCursor = Null;

                         var objTableStart = Null;

                         var objBubble = Null;

                         var strField1 = "";

                         var strField1 = "";

                         var nColIndex = 0;

                         var nRows = 0;

                         

                         objCursor = objPlugIn.AuthenticView.Selection;

                         If (objCursor.IsInDynamicTable())

                         

                                 // calculate current column index

                                 nColIndex = 0;

                                 While (True)

                                 {

                                         try { objCursor.GotoPrevious(11); }

                                 catch (err) { break; }

                                 nColIndex++;

                         }

 

                         // GoTo begin of table

                         objTableStart = objCursor.ExpandTo(9).CollapsToBegin().Clone();

 

                         // count number of table rows

                         nRows = 1;

                         While (True)

                         {

                                 try { objTableStart.GotoNext(10); }

                         catch (err) { break; }

                         nRows++;

                         }

 

                         // bubble sort through table

                         For (var i = 0; i < nRows - 1; i++) {

                                 for(var j 0; j < nRows-i-1; j++) {

                                         objBubble objCursor.ExpandTo(9).CollapsToBegin().Clone();

                                         // Select correct column in jth table row

                                         objBubble.GotoNext(6).Goto(10,j,2).Goto(11,nColIndex,2).ExpandTo(6);

                                         strField1 = objBubble.Text;

                                         strField2 = objBubble.GotoNext(10).Goto(11,nColIndex,2).ExpandTo(6).Text;

                                         if(strField1 > strField2) {

                                                 if(!objBubble.MoveRowUp()) {

                                                         alert('Table row move is not allowed!');

                                                         return;

                                                 }

                                         }

                                 }

                         }

                 }

         </SCRIPT>

 </head>

 

 <body>

         <Object id="objPlugIn" 

         <!-- CodeBase selects 32-bit CAB file (AuthenticBrowserEdition.CAB) -->

         <!-- or 64-bit Cab file (AuthenticBrowserEdition_x64.CAB) -->

                 codeBase="http://myCabfileLocation/AuthenticBrowserEdition.CAB#Version=12,3,0,0" 

         <!-- Class Id for 32-bit and 64-bit CAB files is the same -->

                 classid="clsid:B4628728-E3F0-44a2-BEC8-F838555AE780" 

                 width="100%"

                 height="80%"

                 VIEWASTEXT>

                 <PARAM NAME="EntryHelpersEnabled" VALUE="TRUE">

                 <PARAM NAME="SaveButtonAutoEnable" VALUE="TRUE">

         </Object>

         <TABLE>

                 <TR>

                         <TD><Input Type="button" value="Goto Begin" id="B1" onclick="BtnDocumentBegin()"></TD>

                         <TD><Input Type="button" value="Goto End" name="B2" onclick="BtnDocumentEnd()"></TD>

                         <TD><Input Type="button" value="Whole Document" name="B3" onclick="BtnWholeDocument()"></TD>

                         <TD><Input Type="button" value="Select Next Word" name="B4" onclick="BtnSelectNextWord()"></TD>

                 </TR>

                 <TR>

                         <TD><Input Type="button" value="Sort Table by this Column" id="B6" onclick="BtnSortDepartmentOnClick()"</TD>

                 </TR>

         </TABLE>

         <TABLE id=SelTable border=1>

                 <TR><TD id=SelTable_FirstTextPosition></TD><TD id=SelTable_LastTextPosition></TD></TR>

                 <TR><TD id=SelTable_FirstXMLData></TD><TD id=SelTable_FirstXMLDataOffset></TD></TR>

                 <TR><TD id=SelTable_LastXMLData></TD><TD id=SelTable_LastXMLDataOffset></TD></TR>

                 <TR><TD id=SelTable_Text></TD></TR>

         </TABLE>

 </body>

 

 <SCRIPT LANGUAGE=javascript For=objPlugIn EVENT=selectionchanged>

         var CurrentSelection =  Null;

         CurrentSelection = objPlugIn.AuthenticView.Selection;

         SelTable_FirstTextPosition.innerHTML = CurrentSelection.FirstTextPosition;

         SelTable_LastTextPosition.innerHTML = CurrentSelection.LastTextPosition;

         SelTable_FirstXMLData.innerHTML = CurrentSelection.FirstXMLData.Parent.Name;

         SelTable_FirstXMLDataOffset.innerHTML = CurrentSelection.FirstXMLDataOffset;

         SelTable_LastXMLData.innerHTML = CurrentSelection.LastXMLData.Parent.Name;

         SelTable_LastXMLDataOffset.innerHTML = CurrentSelection.LastXMLDataOffset;

 </SCRIPT>

 

</html>

 

© 2017-2023 Altova GmbH