External impact on the web client 1C: Enterprise
The described method allows you to organize the container using html and JavaScript and place the 1C web client in it. At the same time, the container is able to manage the web client, both at the algorithm level and at the style management level. The approach was tested on 1C version 8.2.18.96.
Setup on the web server side
Each 1C web client works with an information base published on a web server. For a more complete integration, the container into which the web client will be embedded must be created on the same server. This will avoid the security problems associated with cross-domain calls. For example, Silverlight and Flash do not allow access to the content of other sites unless the corresponding policies are configured as xml files. Post requests between domains can also be difficult.
Apache configuration is stored in the conf / httpd.conf file
')
You need to change the value of the paths. Below are the values for the c path: /Apache.www - it contains links to the 1C information bases.
DocumentRoot "C:/Apache.www" <Directory "C:/Apache.www">
Presetting
It is better to start the project of the HTML file with a ready-made template, where styles are written for all browsers. A very decent template is located at
html5boilerplate.com
It should be placed in the root directory of documents that was specified when setting up your web browser. The index.html file is currently responsible for the home page - it needs to be edited.
Just in case we set the browser compatibility mode - compatibility with the latest:
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
The template used works with jQuery.
The launch of the 1C web client will occur in the IFrame inside index.html. The first button will be responsible for launching the 1C App, the second for launching the NetBridge application.
<div id="container"> <button id="appButton"> 1</button> <button id="netBridgeButton"> 2</button> <iframe id="iframe"/> </div>
The button handler looks like this:
$(document).ready(function () { $("#appButton").click(function () { $("#iframe").attr("src", "App/ru_RU/?N="); }); $("#netBridgeButton").click(function () { $("#iframe").attr("src", "NetBridge/ru_RU/?N="); }); ...
At this stage, you can affect the startup parameters of the web client. For example, pass the user name (N = Administrator) and password.
Reaction to web client events
The first event that needs to be caught is the event when the 1C web client is loaded and ready to use.
IFrame implements an onload event for which you can subscribe. The problem is that onload web client can be called up to 3 times. such a call is associated with redirections, for example, the 1C web client redirects the web client based on the user's language. By experiment, we managed to establish that the last onload call is connected with the appearance of the WebUI object in the web client. But the initialization process of 1C is not over. At this stage the necessary libraries are not loaded and the interface of the main form is not created. For a sign of creating the main interface, you can take the moment when the variable initialized becomes equal to true.
The variables of the 1C web client can be accessed through the structure:
cw = $("#iframe").get(0).contentWindow;
Handlers will look like this:
$(document).ready(function () { ... $('#iframe').load(function () {
As a result of the event chain, the desktopLoadedComplete function will be called:
desktopLoadedComplete = function () { var cw = $("#iframe").get(0).contentWindow; if ($("#iframe").get(0).contentWindow.Web.Application.initialized) {
In desktopLoadedComplelte, you can affect the 1C form. For example, make the section selection letters crossed out. The jQuery construction is suitable for this:
$('span.themeLink', $("#iframe").contents()).css('text-decoration', 'line-through');
The winManager.controls ["themes"] object of type WebUI.ThemesPanel is responsible for the sections window. This type is inherited from WebUI.NavigationControl, which in turn is inherited from WebUI.Control and Web.Events.EventsBase.
Experiencedly managed to connect to the partition switching event. It looks like this:
themes = cw.winManager.controls["themes"]; themes.setListener(handleEvents);
The handleEvents event handler receives several parameters, among which is the source of the event, the event code. To analyze the partition switching, the handler will be as follows:
handleEvents = function (sender, eventId, data0) { var cw = $("#iframe").get(0).contentWindow; if (eventId == cw.Web.Events.UIThemeButtonClickedEvent) { alert("eventId = Web.Events.UIThemeButtonClickedEvent"); cw.winManager.handleEvents(sender, eventId, data0); } }
When the partition is switched, a dialog box will be called up and control will be transferred to the native event handler 1C.
findings
Html, JavaScript and jQuery provide powerful tools for managing the 1C web client from the outside. Parameters transfer (login, password), design and style management, event subscription are available. Web client 1C contains a powerful framework that takes a long time to deal with it.
The article does not cover the operation of calling server and client procedures, but theoretically this possibility exists.
The article is also interesting when using the HTML field on a web client without the proposed technology. Since in this case, the entire infrastructure of 1C is also available through the parent window. In theory, when called in such a context of server procedures, it is possible to organize interaction between user html-code and native 1C controls. This option is an alternative to using WebBrowser Control, which means unbinding from Windows.
Website source code:
web-site.zip (86,88 kb)