Documentation

BX24.openApplication

void BX24.openApplication([
    Object parameters[,
    Function closeCallback
    ]
]);

A pop-up window with application will open when this method is called. Parameter data from the 'parameter' will be passed to the application. CloseCallback handler will be called when closing the pop-up window.

Parameters

ParameterDescription
parameters Object with parameters which will be passed to the opened application as a JSON-string
closeCallback Application closing handler

~Is blocked for placements CRM_*_LIST_MENU.

Example

The same example for BX24.openApplication and BX24.closeApplication

<script src="//api.bitrix24.com/api/v1/"></script>
<?
// input data breakdown  
$placementOptions = array();
if(array_key_exists('PLACEMENT_OPTIONS', $_REQUEST))
{
	$placementOptions = json_decode($_REQUEST['PLACEMENT_OPTIONS'], true);
}

// If the app is not deployed, display an open button, if the app is not being closed
if(!isset($placementOptions['opened']))
{
?>
	<span onclick="openApplication()">Open</span>
<?
}
else
{
?>
	<span onclick="closeApplication()">Close</span>
<?
}

?>
<script>
	function openApplication()
	{
		BX24.openApplication(
			{
				'opened': true // data, passed to the opened application
			},
			function()
			{
				// this handler will activate, if the application is closed
				alert('Application closed!')
			}
		);

		setTimeout(closeApplication, 15000); // to close automatically after 15 seconds
	}

	function closeApplication()
	{
		BX24.closeApplication();
	}
</script>

Example with "slider" window

BX24.openApplication(
	{
		'opened': true,
		'bx24_width': 450,// int
		'bx24_label': {
			'bgColor':'pink', // aqua/green/orange/brown/pink/blue/grey/violet
			'text': 'my task',
			'color': '#07ff0e',
		},
		'bx24_title': 'my title', // str
		//'bx24_leftBoundary': 300, //int
	},
	function()
	{
		console.log('Application closed!')
	}
);

In case an application is static without a backend, designed using HTML and JS only, you need to pass any flag when calling BX24.openApplication() to determine if it can be opened via BX24.openApplication and check if this flag is available in BX24.placement.info() inside the app.



© «Bitrix24», 2001-2024
Up