the Internet Windows Android

HTML dissembly document in 1C. Creating a reference to the database object

27
When you integrate 1C with websites always fails to transfer some data to the web server. Whether it is the transfer of a request parameters to receive data from a web server in 1C or data transmission from 1C, which ... 14
The developers on the 1C platform sometimes there is a task for the interaction of the system 1C: an enterprise with various postal programs and protocols. 1C Enterprise 8.0 has quite convenient means to send ... 9
When exchanging data with websites, JSON format is often used. Unfortunately, in 1C there are no standard procedures for working with this format. In the process of implementing one of the projects, I developed a number of procedures and ... 8
JSON format in 1C to version 8.3.6 is not implemented, but will lower I will give examples of functions that can be used for a full operation of JSON in 1C previous versions. JSON (JavaScript Object Notation) is text format Data exchange, ... 5
In this article, I will try to describe the site parsing process with 1C with example. This article is not instructions for use, but only demonstrates the features of 1C. What we have? 1. Website on the Internet, on which ...

During the implementation of a single project, it was necessary to execute JavaScript (hereinafter JS) the code for controlling the object of the fieldhtmldi, to obtain the result in 1C. The above examples, in the following articles, seemed not very convenient to use (purely personal opinion). It was decided to try to find another, simpler, decision, in search of no more than 1 day.

Div.SetAttribute ("OnClick", "Alert (" Coordinates ");");

Perform script

Div.Click ();

TA-DAH. everything is working

Procedure executing (Textscript) Div \u003d elements. Addiction. BetelementByid ("Test"); Div.SetAttribute ("OnClick", textscript); Div.Click (); Extrudresses

Update from 02.08.2016

In the commets, another JS call (thanks) was proposed if you have the ability to change the HTML document code, you can register the function in it and then call it. Transferring code to it on JS.

and then in 1C:

Elements. Focused.ParentWindow.exec ("Alert (OK") ");

Return of the result js in 1c

To transmit the result of the script in 1C from the object object, we will use the event. We will learn to the fieldHTMLD Focument, the entry event that receives on the input 3 of the parameter:

  1. The element of which occurred an event (field itself)
  2. Object event
  3. Sign of standard behavior

To call an event when you click need to execute the following JS code

VAR EVT \u003d Document.CreateEventObject (); // Create an empty object event EVT.PropertyName \u003d "Funk1"; // In props PropertyName, I propose to place the name of the result (something like a type, or the name of the function from which data was received) EVT.DATA \u003d "156"; // In the DATA props, we will transmit the result data document.body.fireEvent ("OnClick", EVT); // Perform an event when you press the fieldhtmld

By completing this JS code in the procedure when you press the event, the event will come by us. Which is quite convenient to handle.

An example of a response sample.

& Clause // We obtain the name and result of the event of the treatment procedure (element, data, standardworking) NameProduction \u003d Dannay.Event.PropertyName; PATTERATIONS \u003d DANNUESE.EVENT.DATA; If the OPERATION name \u003d "" then // not our return event; Ended; If the function is the function \u003d "Funki1" then // Processing The result Inadecited Operation \u003d "Funk2" then // Processing Result // ...... ended; Extrudresses

This method eliminates the use of expectation handlers, and provides a convenient event identifier. According to the identifier, we know exactly what data came to us, and how to disassemble them.

Additions from 03/26/2016

And in this place, neponyatki occurred (the mistitbake is fed only on plappa 8.3.5.1570, but in order to warn these situations in the random, I will give a decision) the very reason - When you restart the form with the HTML field of the document at the time of calling the procedure when you click on the HTML field, the platform challenge shindleled and the whole valve COM Object (HTMLFILE) occurred: an indefinite error). The solution was the disconnection of the CT cLICK Events, and disabling event pop-up mode. How to do it look below.

// Disable Event Backup

EVT.CANCELBUBBLE \u003d TRUE;

// Disable Standard Behavior

EVT.RETURNVALUE \u003d FALSE;

As a result, to transfer data to 1C from JS, we will get a function.

Function Return1c (Name, Data) (VAR EVT \u003d Document.CreateEventObject (); EVT.PropertyName \u003d Name; EVT.DATA \u003d DATA; EVT.CancelBubble \u003d True; EVT.RETURNVALUE \u003d FALSE; Document.FireEvent ("OnClick", EVT ););

Output.

Combining these methods, you can quite easily run the JS code you need, and receive data in 1C for further processing.

Example of implementing B.

Sometimes there is a need to display any webpage directly on the form. I will consider this feature of the 1C platform on the example of a page shape with search engine Yandex, and with the search results for the word entered in the form field.

Those. This page is:

Picture 1

To begin with, creating external processing, Add props "Address" with a "string" type, unlimited length.

Figure 2.

Create a form of processing. The props "Address" will be transferred to the form twice. One of the elements of the requisite form to rename to the "page", change the view of the element to the "HTML document field".

The form will take the form:

Figure 3.

Let's start processing in the "Enterprise" mode and introduce the address of an arbitrary Internet resource. And we get the result:

Figure 4.

How to make it so that the Yandex page is displayed in the page "page", but already with the search results for some word?

We will add the requisite of the form: "KeyEvoisloovo", we move to the form.

If you look close to the address that appears in the Yandex address bar after searching for the keyword "1C" (and it will be: "http://yandex.ru/yandsearch?text\u003d1%D1%81"), then you can see that the word entered is encrypted and transmitted to the post-variable text. From here we conclude that it remains only to figure out how to get the encrypted value of the request.

If you dig a little, you can find out that for encoding variables in URLs, you can use the Java-Script function "Encodeuricomponent". It is possible, of course, to select the code for each alphabet symbol and write an encoder yourself, and you can use the capabilities of the WScript components that can be connected from 1C.

So, what we need:

A) Connect WScript

B) on the basis of keywords Collect the script that will receive a value returned by the "ENCODEURICOMPONENT" function when transmitting to it as the parameter of our word, and then the result will be recorded in a text file with a defined directory in advance

C) from 1c receive a text file created using WScript and read it.

If we speak in the embedded language, it sounds like this:

& Slide the procedure of key oscillator (element) object. Address \u003d " http: //yandex.ru/yandSearch?text\u003d "+ ConvertChelloeslovo (); Extrudresses & Svalette Confratchevo-oscillate function () FIELLAVRA \u003d OPERATEQUMEN File ("js" ) ; Catalog Scanning \u003d Strust (Catalog Lengthyls ()," \" , " /" ) ; Catobook \u003d Strust (catalog"C: /" , "C: //"); Template document \u003d new text document; Text Document. Settext ("Value \u003d ENCODEURICOMPONENT ("" "+ Key cello +" "" ) ; | FSO. \u003d WScript. CreateObject ("" Scripting . FileSystemObject." " ) ; | F. \u003d FSO. CreateTextFile ("" "+ Catobook +" Test . TXT." + " " " , TRUE); | F. . Writeline (Value); | F. . Close ();"); Text document. Record (name FIELLS, encoding. ANSI); WSHShell \u003d new COMBACK (" WScript . Shell."); WSHShell. Run (" WScript . EXE"" "+ Name FIELLS +" "" ", 0, - 1); Delete Files (name FIELLS); Text document \u003d New Template Document; Text Focument. Read (Catalog Varmetyls () +" Test . TXT."); Row \u003d Text document. To get (); Returns SOKRLP (string); endfunction