AttachDispatch Method



 
The AttachDispatch method permits referencing an object through the dialog HTML page.


Syntax

    SKHtmlDialog.AttachDispatch(newname, obj)
Parameters
    newname String that contains the name of the object in the dialog.
    obj Object to make available in the dialog.
Return Value
    None.
Remarks
    None.
Examples
    When the Payment Module of SiteKiosk is active, the following example permits using the currency formatter object from within the dialog HTML page. This demonstrates how to attach SiteKiosk objects to a dialog.

    <SCRIPT TYPE="text/javascript">
    window.external.InitScriptInterface();
    mycfm = SiteKiosk.Plugins("SiteCash").CreateCurrencyFormatter();
    mydialog = SiteKiosk.SiteKioskUI.CreateHTMLDialog();
    mydialog.Border = true;
    mydialog.ScrollBars = true;
    mydialog.Sysmenu = true;
    mydialog.Title = true;
    mydialog.Width = 300;
    mydialog.URL = "http://www.myserver.com/mydialog.html";
    mydialog.AttachDispatch("mycfm", mycfm);
    mydialog.ShowDialog();
    </SCRIPT>
    

    The follwing example shows that you can attach any object to the dialog.

    Listing for the file that creates the dialog:
    
    <html>
    <head>
    	<title>CreateHTMLDialog Test Page</title>
    </head>
    <SCRIPT TYPE="text/javascript">
    	window.external.InitScriptInterface();
    	
    	function CreateNewDialog(){
    		var MyObject = new Object();
    		MyObject.Testvalue = 1;
    	
    		var MyDialog = SiteKiosk.SiteKioskUI.
    		CreateHTMLDialog();
    		MyDialog.Border = true;
    		MyDialog.ScrollBars = true;
    		MyDialog.Sysmenu = true;
    		MyDialog.Title = true;
    		MyDialog.Width = 350;
    		//Change according to path and name 
    		of the file for the dialog
    		MyDialog.URL = "file://C:\\Program 
    		Files (x86)\\SiteKiosk\\Html\\dialog.html";
    		MyDialog.AttachDispatch("DialogObject", 
    		MyObject);
    		MyDialog.ShowDialog();
    	}
    </SCRIPT>
    <body>
    	<input type="button" onclick="CreateNewDialog();" 
    	value="CreateHTMLDialog Test" />
    </body>
    </html>
    
    Listing for the file loaded in the dialog:
    
    <html>
    <head>
    	<meta http-equiv="X-UA-Compatible" 
    	content="IE=EmulateIE7" />
    	<title>HTMLDialog Test Page</title>
    </head>
    <SCRIPT TYPE="text/javascript">
    	window.external.InitScriptInterface();
    	
    	function GetExternalObjectValue(){
    		document.getElementById("resultspan").
    		innerHTML = DialogObject.Testvalue;
    	}
    	
    	function OnOK(){
    		Dialog.CloseDialog();
    	}
    </SCRIPT>
    <body>
    	<input type="button" onclick="GetExternalObjectValue();" 
    	value="GetExternalObjectValue" />
    	<span id="resultspan">...</span>
    	<input type="button" value="Close" onclick="OnOK();" />
    </body>
    </html>
    

Applies to
    SiteKiosk v5.0 (and later versions).

Back to top