CN109815429B - Browser page closing processing method and device - Google Patents

Browser page closing processing method and device Download PDF

Info

Publication number
CN109815429B
CN109815429B CN201910096254.0A CN201910096254A CN109815429B CN 109815429 B CN109815429 B CN 109815429B CN 201910096254 A CN201910096254 A CN 201910096254A CN 109815429 B CN109815429 B CN 109815429B
Authority
CN
China
Prior art keywords
browser
function
callback function
called
callback
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910096254.0A
Other languages
Chinese (zh)
Other versions
CN109815429A (en
Inventor
俞亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Suixun Electronic Technology Co ltd
Original Assignee
Tianjin ByteDance Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tianjin ByteDance Technology Co Ltd filed Critical Tianjin ByteDance Technology Co Ltd
Priority to CN201910096254.0A priority Critical patent/CN109815429B/en
Publication of CN109815429A publication Critical patent/CN109815429A/en
Application granted granted Critical
Publication of CN109815429B publication Critical patent/CN109815429B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The disclosure provides a browser page closing processing method and device, wherein the method comprises the following steps: monitoring whether a first callback function in a browser script file is called or not in the running process of a browser; if the first callback function is monitored to be called, triggering to run a preset blocking function so as to send a calling parameter of the first callback function to a server corresponding to the browser; and the first callback function is a function used for closing the current page by the browser. By the method, the browser closing parameters can be sent to the server under the condition that the user experience is not influenced, the user experience is improved, and the technical problem that the browser page can be closed only by clicking twice due to the fact that the callback function is blocked by the popup window in the prior art is solved.

Description

Browser page closing processing method and device
Technical Field
The present disclosure relates to the field of computer application technologies, and in particular, to a method and an apparatus for closing a browser page.
Background
At present, when a browser is closed, a browser closing parameter is sent to a server through calling of a popup blocking callback function, so that the browser can count information of a current page used by a user conveniently. Because the popup can be displayed in the browser page, the user can completely close the browser page only by clicking twice, the operation process is not simple and convenient enough, and the use experience of the user is influenced.
Therefore, how to send the shutdown parameters to the server without affecting the user experience becomes an urgent problem to be solved.
Disclosure of Invention
The disclosure provides a browser page closing processing method and device, and solves the problem that in the prior art, a browser page can be closed only by clicking twice due to the fact that calling of callback functions is blocked by a popup window.
Therefore, the first aspect of the disclosure provides a browser page closing processing method, so as to send a browser closing parameter to a server without affecting user experience, thereby improving user experience.
The second aspect of the present disclosure provides a browser page closing processing apparatus.
A third aspect of the present disclosure provides an electronic device.
A fourth aspect of the disclosure proposes a non-transitory computer-readable storage medium.
A fifth aspect of the disclosure proposes a computer program product.
An embodiment of a first aspect of the present disclosure provides a method for closing a browser page, including:
monitoring whether a first callback function in a browser script file is called or not in the running process of a browser;
if the first callback function is monitored to be called, triggering to run a preset blocking function so as to send a calling parameter of the first callback function to a server corresponding to the browser;
and the first callback function is a function used for closing the current page by the browser.
According to the browser page closing processing method, whether a first callback function in a browser script file is called or not is monitored in the browser running process, and a preset blocking function is triggered to run when the first callback function is monitored to be called, so that a call parameter of the first callback function is sent to a server corresponding to the browser, wherein the first callback function is a function used for closing a current page of the browser. Therefore, the first callback function is blocked by triggering and running the preset blocking function to be called, so that the situation that the browser page can be closed only by clicking twice by a user is avoided, the calling parameter of the first callback function is sent to the server corresponding to the browser by triggering and running the preset blocking function, the calling parameter is sent to the server while the user use experience is not influenced, and the server can normally acquire the use information of the user.
An embodiment of a second aspect of the present disclosure provides a browser page closing processing apparatus, including:
the monitoring module is used for monitoring whether a first callback function in the browser script file is called or not in the running process of the browser;
the triggering module is used for triggering and running a preset blocking function when the first callback function is monitored to be called so as to send a calling parameter of the first callback function to a server corresponding to the browser;
and the first callback function is a function used for closing the current page by the browser.
The browser page closing processing device according to the embodiment of the disclosure monitors whether a first callback function in a browser script file is called or not in a browser running process, and triggers running of a preset blocking function when the first callback function is monitored to be called, so as to send a call parameter of the first callback function to a server corresponding to the browser, wherein the first callback function is a function used for closing a current page by the browser. Therefore, the first callback function is blocked by triggering and running the preset blocking function to be called, so that the situation that the browser page can be closed only by clicking twice by a user is avoided, the calling parameter of the first callback function is sent to the server corresponding to the browser by triggering and running the preset blocking function, the calling parameter is sent to the server while the user use experience is not influenced, and the server can normally acquire the use information of the user.
An embodiment of a third aspect of the present disclosure provides an electronic device, including: a processor and a memory; the processor reads the executable program code stored in the memory to run a program corresponding to the executable program code, so as to implement the browser page closing processing method according to the embodiment of the first aspect.
A fourth aspect of the present disclosure provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a browser page closing processing method according to the first aspect of the present disclosure.
A fifth aspect of the present disclosure provides a computer program product, where instructions in the computer program product, when executed by a processor, perform the browser page closing processing method according to the first aspect.
Additional aspects and advantages of the disclosure will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the disclosure.
Drawings
The foregoing and/or additional aspects and advantages of the present disclosure will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a schematic flowchart of a browser page closing processing method according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a browser page closing processing method according to another embodiment of the present disclosure;
fig. 3 is a flowchart illustrating a browser page closing processing method according to another embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a browser page closing processing apparatus according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a browser page closing processing apparatus according to another embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a browser page closing processing apparatus according to yet another embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of a browser page closing processing apparatus according to yet another embodiment of the present disclosure;
FIG. 8 is a schematic structural diagram of an electronic device for implementing an embodiment of the present disclosure; and
fig. 9 is a schematic diagram illustrating a computer-readable storage medium according to an embodiment of the present disclosure.
Detailed Description
Reference will now be made in detail to the embodiments of the present disclosure, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the drawings are exemplary and intended to be illustrative of the present disclosure, and should not be construed as limiting the present disclosure.
A browser page closing processing method and apparatus according to an embodiment of the present disclosure are described below with reference to the drawings.
When the browser is closed, the browser closing parameters are sent to the server through the call of the popup blocking callback function, so that the browser can count the information of the current page used by a user conveniently. However, the popup may be displayed in the browser page, affecting the user experience.
In the related art, in order to improve the user experience, the function of monitoring the callback function of closing the webpage is limited, so that the callback function is not blocked by a popup window when the browser is closed, which easily causes that the closing parameter is not sent to the server when the browser page is closed, and the server cannot count the information of the user using the page.
In order to solve the above problem, the present disclosure provides a browser page closing processing method, so as to send a browser closing parameter to a server without affecting user experience.
Fig. 1 is a flowchart illustrating a browser page closing processing method according to an embodiment of the present disclosure.
As shown in fig. 1, the browser page closing processing method includes the following steps:
step 101, in the running process of a browser, monitoring whether a first callback function in a browser script file is called, wherein the first callback function is a function used by the browser to close a current page.
In the running process of the browser, when a user executes an operation of closing the browser, for example, the user clicks a closing function key "X" in the upper right corner of a browser page, at this time, a first callback function in a browser script file is called.
To know whether the first callback function is called, the first callback function may be monitored.
As an example, a corresponding hook function may be set for the first callback function, and when the first callback function is called, Windows calls the hook function. When Windows calls a callback function, it may be determined that a first callback function in the browser script file is called.
As an example, it may be detected whether the first callback function is assigned to a program for blocking the function from being called, and if so, it is determined that the first callback function is called.
In a possible implementation manner of the embodiment of the present disclosure, before monitoring whether the first callback function in the browser script file is called, the method further includes: when a page is loaded by a browser, acquiring a script file of the browser; and assigning a value to the first callback function by using a preset blocking function.
As an example, an onbeforunload first callback function of a page may be registered in a script file of a browser, and when the browser loads the page, the script file is obtained, and a preset blocking function is used to assign a value to the onbeforunload.
For example, the first callback function may be assigned by:
Window.Onbeforeunload=function(){
// a preset blocking function;
}。
the script file of the browser is obtained when the browser loads the page, and the first callback function is assigned with the value by the aid of the preset blocking function, so that a foundation is laid for blocking execution of the first callback function by the aid of the blocking function.
And 102, if it is monitored that the first callback function is called, triggering to run a preset blocking function, so as to send a calling parameter of the first callback function to a server corresponding to the browser.
The preset blocking function includes a code for sending a call parameter to the server, the call parameter is generated when the first callback function is called, the call parameter is included in the first callback function, the call parameter may include current time, a mode for triggering closing of the current page (for example, refreshing the page or closing the page), and the like, the call parameter sent by the blocking function to the server may be selected according to the requirement of the server, for example, when the server only needs to acquire the time for closing the page, the call parameter sent by the blocking function to the server may only include the current time.
In this embodiment, when it is monitored that the first callback function is called, the preset blocking function is triggered to run, because the blocking function includes a code for sending a call parameter to the server, the blocking function is triggered to run when it is monitored that the first callback function is called, so that not only is the running of the first callback function blocked, but also the call parameter is sent to the server, and the call for blocking the first callback function can be realized without a popup window, so that the user experience is not affected.
In a possible implementation manner of the embodiment of the present disclosure, the first callback function has a plurality of call parameters, and the call parameters that different browsers need to send to the server may be different, for example, a server corresponding to a Chrome browser needs the Chrome browser to send current time and trigger a manner of closing a current page, and a server corresponding to a google browser needs the google browser to send current time. In order to meet the requirements of different servers, in this embodiment, before triggering and running a preset blocking function, a target call parameter to be sent to a server in the multiple call parameters may be determined according to the type of the browser.
As an example, the blocking function may include a corresponding relationship between a browser type and a call parameter, when the blocking function is assigned to the first callback function, a target call parameter corresponding to the browser type is determined according to the currently running browser type, and when a preset blocking function is triggered to run, the blocking function sends the target call parameter to the server.
According to the browser page closing processing method, whether a first callback function in a browser script file is called or not is monitored in the browser running process, and a preset blocking function is triggered to run when the first callback function is monitored to be called, so that a calling parameter of the first callback function is sent to a server corresponding to the browser, wherein the first callback function is a function for closing a current page of the browser. Therefore, the first callback function is blocked by triggering and running the preset blocking function to be called, so that the situation that the browser page can be closed only by clicking twice by a user is avoided, the calling parameter of the first callback function is sent to the server corresponding to the browser by triggering and running the preset blocking function, the calling parameter is sent to the server while the user use experience is not influenced, and the server can normally acquire the use information of the user.
In a possible implementation manner of the embodiment of the present disclosure, it is further required to monitor a condition that the function is exited from the blocking function, so that when the condition that the function is exited from the blocking function is met, the blocking of the first callback function is ended, so that the browser page is successfully closed after the first callback function is executed. The specific process of monitoring for conditions that satisfy the exit blocking function is described in detail below with reference to fig. 2 and 3.
As shown in fig. 2, on the basis of the embodiment shown in fig. 1, after step 102, the following steps may be further included:
step 201, monitoring whether a second callback function or a third callback function in the browser script file is called, wherein the second callback function is a function called by the browser when data transmission to the server is successful, and the third callback function is a function called by the browser when data transmission to the server is failed.
In this embodiment, after the blocking function is triggered to run, the browser sends the call parameter to the server by executing a code for sending the call parameter to the server in the blocking function, and waits for a response message returned by the server. After successfully receiving the calling parameters sent by the browser, the server returns response information of successful sending to the browser; and when the calling parameters received by the server are not matched with the required calling parameters, returning and sending the identified response information to the browser. And then, the browser calls different callback functions according to the type of the received response information.
Specifically, when the browser receives response information which is successfully sent, the second callback function is called, and when the browser receives response information which is unsuccessfully sent, the third callback function is called. In addition, when response information returned by the server is not acquired within a period of time after the browser sends the calling parameter to the server, the third callback function is also called.
As an example, whether the second callback function or the third callback function is called is monitored, corresponding hook functions may be set for the second callback function and the third callback function, respectively, and whether the second callback function or the third callback function is called is determined according to the called hook functions.
As an example, a flag postState may be initialized, the initial value of which is set to 0, the value of postState is set to 1 when the second callback function is called, and the value of postState is set to-1 when the third callback function is called, so that whether the second callback function or the third callback function is called can be determined by reading the value of postState.
Step 202, if the second callback function is called, the blocking function is ended, so that the browser successfully calls the first callback function.
In this embodiment, when it is monitored that the second callback function is called, the blocking function is ended, and the first callback function is executed, so that the browser successfully calls the first callback function.
In step 203, if the third callback function is called, it is determined whether the time interval between the current time and the time when the first callback function is called is equal to the threshold.
The threshold may be preset, for example, by defining a timeOut to represent the threshold, and setting the value of the timeOut to 500 ms.
In this embodiment, when it is detected that the third callback function is called, a current time and a time at which the first callback function is called are obtained, where the current time may be represented by defining a nowTime, and when it is detected that the third callback function is called, a value is assigned to the nowTime by using the time at which the third callback function is detected to be called; and when the first callback function is monitored to be called, assigning a value to the startTime by utilizing the monitored moment of the first callback function. And then calculating the difference value between the nowTime and the startTime, and comparing the obtained difference value with a preset threshold value to judge whether the time interval between the current time and the time when the first callback function is called is equal to the threshold value. If the difference is equal to the threshold, go to step 204; if the difference is smaller than the threshold, step 205 is executed.
And step 204, if yes, ending the blocking function so that the browser successfully calls the first callback function.
In this embodiment, when it is determined that the time interval between the current time and the time when the first callback function is called is equal to the threshold, the blocking function is ended, so that the browser successfully calls the first callback function.
Step 205, if the value is smaller than the threshold value, triggering the browser to re-execute the operation of sending the calling parameter of the first callback function to the server corresponding to the browser.
In this embodiment, when it is determined that the time interval between the current time and the time when the first callback function is invoked is smaller than the threshold, the browser is triggered to re-execute the operation of sending the invocation parameter of the first callback function to the server corresponding to the browser, so as to send the invocation parameter to the corresponding server as successfully as possible.
The browser page closing processing method of this embodiment monitors whether a second callback function or a third callback function in a browser script file is called, where the second callback function is a function called by the browser when data transmission to the server is successful, the third callback function is a function called by the browser when data transmission to the server is failed, when the second callback function is called, a blocking function is ended, so that the browser successfully calls the first callback function, when the third callback function is called, it is further determined whether a time interval between a current time and a time when the first callback function is called is equal to a threshold, and when the time interval is equal to the threshold, the blocking function is ended, when the time interval is smaller than the threshold, the browser is triggered to re-execute an operation of sending a call parameter of the first callback function to a server corresponding to the browser, so that the blocking function is exited when the call parameter is successfully sent to the server or when the call parameter is failed but reaches a preset time, the method and the device ensure that the browser successfully closes the page, and the calling parameter is sent again when the sending identification does not reach the preset time, so that the success rate of sending the calling parameter is improved.
The present disclosure also provides another method for determining whether a condition for exiting the blocking function is satisfied, as shown in fig. 3, on the basis of the embodiment shown in fig. 1, after step 102, the method may further include the following steps:
step 301, it is monitored whether the time interval between the current time and the time when the first callback function is called is equal to a threshold.
And 302, if yes, ending the blocking function so that the browser successfully calls the first callback function.
In this embodiment, after the preset blocking function is triggered to run, whether a time interval between the current time and the time when the first callback function is called is equal to a threshold value may be monitored in real time. When the time interval is equal to the threshold, the blocking function is ended.
For example, a timer may be predefined, an initial value of the timer is set to 0, when it is detected that the first callback function is called, the timer is started to start timing, and a value of the timer is monitored in real time, where the value of the timer is a time interval between the current time and the time when the first callback function is called. And when the monitored value of the timer is the same as the preset threshold value, ending the blocking function, and executing the first callback function so that the browser successfully calls the first callback function.
According to the browser page closing processing method, whether the time interval between the current time and the called time of the first callback function is equal to the threshold value or not is monitored, and the blocking function is ended when the time interval is equal to the threshold value, so that the browser successfully calls the first callback function, therefore, the time for calling the first callback function is used as a condition for judging whether the blocking function exits or not, the blocking function exits when the time for calling the first callback function reaches the threshold value, the situation that the browser cannot close the page due to the fact that the browser waits for the first callback function to be executed completely is avoided, and user experience is improved.
It should be noted that the manners shown in fig. 2 and fig. 3 for determining whether to exit the blocking function may be executed separately or together, and when the two manners are executed together, if any one of the manners meets the condition for exiting the blocking function, the browser ends the blocking function, so that the browser successfully calls the first callback function, thereby ensuring that the browser immediately closes the page and improving the user experience.
In order to implement the above embodiment, the present disclosure further provides a browser page closing processing apparatus.
Fig. 4 is a schematic structural diagram of a browser page closing processing apparatus according to an embodiment of the present disclosure.
As shown in fig. 4, the browser page close processing means 40 includes: a monitoring module 410 and a triggering module 420.
The monitoring module 410 is configured to monitor whether a first callback function in a browser script file is called or not in the browser running process; the first callback function is a function used by the browser to close the current page.
The triggering module 420 is configured to trigger to run a preset blocking function when it is monitored that the first callback function is called, so as to send a calling parameter of the first callback function to a server corresponding to the browser.
In a possible implementation manner of the embodiment of the present disclosure, the first callback function has a plurality of call parameters, and before the triggering module 420 triggers and runs the preset blocking function, the triggering module is further configured to determine, according to the type of the browser, a target call parameter to be sent to the server in the plurality of call parameters.
In a possible implementation manner of the embodiment of the present disclosure, as shown in fig. 5, on the basis of the embodiment shown in fig. 4, the browser page closing processing apparatus 40 further includes:
the preprocessing module 400 is configured to obtain a script file of the browser when the browser loads a page, and assign a value to the first callback function by using a preset blocking function.
The script file of the browser is obtained when the browser loads the page, and the first callback function is assigned with the value by the aid of the preset blocking function, so that a foundation is laid for blocking execution of the first callback function by the aid of the blocking function.
In a possible implementation manner of the embodiment of the present disclosure, as shown in fig. 6, on the basis of the embodiment shown in fig. 4, the browser page closing processing apparatus 40 further includes:
and the condition monitoring module 430 is configured to monitor whether a second callback function or a third callback function in the browser script file is called, where the second callback function is a function called by the browser when data transmission to the server is successful, and the third callback function is a function called by the browser when data transmission to the server is failed.
The first processing module 440 is configured to end the blocking function when the second callback function is called, so that the browser successfully calls the first callback function.
The second processing module 450 is configured to, when the third callback function is called, determine whether a time interval between the current time and the time when the first callback function is called is equal to a threshold, and when the time interval is equal to the threshold, end the blocking function, so that the browser successfully calls the first callback function.
In this embodiment, the second processing module 450 is further configured to trigger the browser to re-execute an operation of sending the call parameter of the first callback function to a server corresponding to the browser when a time interval between the current time and the time when the first callback function is called is smaller than a threshold.
By monitoring whether a second callback function or a third callback function in a browser script file is called, wherein the second callback function is a function called when the browser successfully sends data to the server, the third callback function is a function called when the browser fails to send data to the server, when the second callback function is called, a blocking function is finished so that the browser successfully calls the first callback function, when the third callback function is called, whether a time interval between the current time and the time when the first callback function is called is equal to a threshold value or not is further judged, when the time interval is equal to the threshold value, the blocking function is finished, when the time interval is less than the threshold value, the browser is triggered to re-execute the operation of sending the calling parameter of the first callback function to the server corresponding to the browser, so that the blocking function is quitted when the calling parameter is successfully sent to the server or when the calling parameter is failed but reaches a preset time, the method and the device ensure that the browser successfully closes the page, and the calling parameter is sent again when the sending identification does not reach the preset time, so that the success rate of sending the calling parameter is improved.
In a possible implementation manner of the embodiment of the present disclosure, as shown in fig. 7, on the basis of the embodiment shown in fig. 4, the browser page closing processing apparatus 40 further includes:
an exit module 460, configured to monitor whether a time interval between the current time and the time when the first callback function is invoked is equal to a threshold; if yes, the blocking function is ended, so that the browser successfully calls the first callback function.
By monitoring whether the time interval between the current time and the called time of the first callback function is equal to the threshold value or not and ending the blocking function when the time interval is equal to the threshold value, the browser can successfully call the first callback function, therefore, the time for calling the first callback function is used as a condition for judging whether the blocking function exits or not, the blocking function exits when the time for calling the first callback function reaches the threshold value, the situation that the browser cannot close the page because the browser waits for the first callback function to finish executing is avoided, and the user experience is improved.
It should be noted that the foregoing explanation on the browser page closing processing method embodiment is also applicable to the browser page closing processing apparatus of the embodiment, and the implementation principle is similar, and is not described herein again.
The browser page closing processing device according to the embodiment of the disclosure monitors whether a first callback function in a browser script file is called or not in a browser running process, and triggers running of a preset blocking function when the first callback function is monitored to be called, so as to send a call parameter of the first callback function to a server corresponding to the browser, wherein the first callback function is a function used for closing a current page by the browser. Therefore, the first callback function is blocked by triggering and running the preset blocking function to be called, so that the situation that the browser page can be closed only by clicking twice by a user is avoided, the calling parameter of the first callback function is sent to the server corresponding to the browser by triggering and running the preset blocking function, the calling parameter is sent to the server while the user use experience is not influenced, and the server can normally acquire the use information of the user.
In order to implement the above embodiments, the present disclosure also provides an electronic device, including: a processor and a memory. The processor reads the executable program code stored in the memory to run the program corresponding to the executable program code, so as to implement the browser page closing processing method according to the foregoing embodiment.
Referring now to FIG. 8, shown is a schematic diagram of an electronic device 800 suitable for use in implementing embodiments of the present disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., car navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 8, an electronic device 800 may include a processing means (e.g., central processing unit, graphics processor, etc.) 801 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage means 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for the operation of the electronic apparatus 800 are also stored. The processing apparatus 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
Generally, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage 808 including, for example, magnetic tape, hard disk, etc.; and a communication device 809. The communication means 809 may allow the electronic device 800 to communicate wirelessly or by wire with other devices to exchange data. While fig. 8 illustrates an electronic device 800 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 809, or installed from the storage means 808, or installed from the ROM 802. The computer program, when executed by the processing apparatus 801, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: monitoring whether a first callback function in a browser script file is called or not in the running process of a browser; if the first callback function is monitored to be called, triggering and running a preset blocking function so as to send a calling parameter of the first callback function to a server corresponding to the browser; the first callback function is a function used by the browser to close the current page.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The name of the module does not constitute a limitation to the module itself in some cases, for example, the monitoring module may also be described as a module for monitoring whether the first callback function in the browser script file is called during the running of the browser.
In order to implement the above embodiments, the present disclosure also proposes a non-transitory computer-readable storage medium on which a computer program is stored, which when executed by a processor implements the browser page closing processing method according to the foregoing embodiments.
Fig. 9 is a schematic diagram illustrating a computer-readable storage medium according to an embodiment of the present disclosure. As shown in fig. 9, a computer-readable storage medium 300 having non-transitory computer-readable instructions 310 stored thereon according to an embodiment of the present disclosure. The non-transitory computer readable instructions 310, when executed by a processor, perform all or part of the steps of the browser page close processing method of the embodiments of the present disclosure described above.
In order to implement the foregoing embodiments, the present disclosure further provides a computer program product, where when instructions in the computer program product are executed by a processor, the method for closing a browser page according to the foregoing embodiments is implemented.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present disclosure, "a plurality" means at least two, e.g., two, three, etc., unless explicitly specifically limited otherwise.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing steps of a custom logic function or process, and alternate implementations are included within the scope of the preferred embodiment of the present disclosure in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the embodiments of the present disclosure.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. The computer readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present disclosure may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Although embodiments of the present disclosure have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure, and that changes, modifications, substitutions and alterations may be made to the above embodiments by those of ordinary skill in the art within the scope of the present disclosure.

Claims (9)

1. A browser page closing processing method is characterized by comprising the following steps:
monitoring whether a first callback function in a browser script file is called or not in the running process of a browser;
if the first callback function is monitored to be called, triggering to run a preset blocking function so as to send a calling parameter of the first callback function to a server corresponding to the browser;
the first callback function is a function used for closing the current page by the browser;
after the triggering operation of the preset blocking function, the method further comprises the following steps:
monitoring whether a second callback function or a third callback function in the browser script file is called, wherein the second callback function is a function called when the browser successfully sends data to the server, and the third callback function is a function called when the browser fails to send data to the server;
and if the second callback function is called, ending the blocking function so that the browser successfully calls the first callback function.
2. The method of claim 1, wherein after monitoring whether the second callback function or the third callback function in the browser script file is called, further comprising:
if the third callback function is called, judging whether the time interval between the current time and the time when the first callback function is called is equal to a threshold value or not;
if yes, ending the blocking function so that the browser can successfully call the first callback function.
3. The method of claim 2, wherein after determining whether a time interval between a current time and a time at which the first callback function is invoked is equal to a threshold, further comprising:
and if the calling parameter is smaller than the threshold value, triggering the browser to re-execute the operation of sending the calling parameter of the first callback function to a server corresponding to the browser.
4. The method of any of claims 1-3, wherein the triggering the running of the preset blocking function further comprises:
monitoring whether a time interval between a current time and a time when the first callback function is called is equal to a threshold value;
if yes, ending the blocking function so that the browser can successfully call the first callback function.
5. A method according to any of claims 1-3, wherein prior to monitoring whether the first callback function in the browser script file is invoked, further comprising:
when the browser loads a page, acquiring a script file of the browser;
and assigning a value to the first callback function by using the preset blocking function.
6. The method of any of claims 1-3, wherein the first callback function has a plurality of call parameters;
before the triggering operation of the preset blocking function, the method further includes:
and determining a target calling parameter to be sent to the server in the plurality of calling parameters according to the type of the browser.
7. A browser page closing processing apparatus, comprising:
the monitoring module is used for monitoring whether a first callback function in the browser script file is called or not in the running process of the browser;
the triggering module is used for triggering and running a preset blocking function when the first callback function is monitored to be called so as to send a calling parameter of the first callback function to a server corresponding to the browser;
the first callback function is a function used for closing the current page by the browser;
the condition monitoring module is used for monitoring whether a second callback function or a third callback function in the browser script file is called or not after the preset blocking function is triggered to run, wherein the second callback function is a function called by the browser when data is successfully sent to the server, and the third callback function is a function called by the browser when the data is failed to be sent to the server;
and the first processing module is used for ending the blocking function when the second callback function is called so as to enable the browser to successfully call the first callback function.
8. An electronic device comprising a processor and a memory;
wherein the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory to implement the browser page closing processing method according to any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium on which a computer program is stored, the program, when executed by a processor, implementing the browser page closing processing method according to any one of claims 1 to 6.
CN201910096254.0A 2019-01-31 2019-01-31 Browser page closing processing method and device Active CN109815429B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910096254.0A CN109815429B (en) 2019-01-31 2019-01-31 Browser page closing processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910096254.0A CN109815429B (en) 2019-01-31 2019-01-31 Browser page closing processing method and device

Publications (2)

Publication Number Publication Date
CN109815429A CN109815429A (en) 2019-05-28
CN109815429B true CN109815429B (en) 2021-03-05

Family

ID=66606100

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910096254.0A Active CN109815429B (en) 2019-01-31 2019-01-31 Browser page closing processing method and device

Country Status (1)

Country Link
CN (1) CN109815429B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110334299B (en) * 2019-06-27 2023-01-06 上海淇馥信息技术有限公司 Popup window display method and device based on address bar monitoring and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101222349A (en) * 2007-01-12 2008-07-16 中国电信股份有限公司 Method and system for collecting web user action and performance data
CN104967630A (en) * 2014-04-10 2015-10-07 腾讯科技(深圳)有限公司 Method and apparatus for processing webpage access request
US9531839B1 (en) * 2014-04-10 2016-12-27 Google Inc. Systems and methods for request isolation protection
CN107390992A (en) * 2017-07-21 2017-11-24 北京三快在线科技有限公司 Webpage manipulation exchange method, device and Website server
CN108280014A (en) * 2018-02-06 2018-07-13 武汉斗鱼网络科技有限公司 A kind of method, apparatus and computer equipment for monitoring browser page
CN109284470A (en) * 2018-10-25 2019-01-29 天津字节跳动科技有限公司 Page window communication means and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101222349A (en) * 2007-01-12 2008-07-16 中国电信股份有限公司 Method and system for collecting web user action and performance data
CN104967630A (en) * 2014-04-10 2015-10-07 腾讯科技(深圳)有限公司 Method and apparatus for processing webpage access request
US9531839B1 (en) * 2014-04-10 2016-12-27 Google Inc. Systems and methods for request isolation protection
CN107390992A (en) * 2017-07-21 2017-11-24 北京三快在线科技有限公司 Webpage manipulation exchange method, device and Website server
CN108280014A (en) * 2018-02-06 2018-07-13 武汉斗鱼网络科技有限公司 A kind of method, apparatus and computer equipment for monitoring browser page
CN109284470A (en) * 2018-10-25 2019-01-29 天津字节跳动科技有限公司 Page window communication means and device

Also Published As

Publication number Publication date
CN109815429A (en) 2019-05-28

Similar Documents

Publication Publication Date Title
CN113938456A (en) Session message top processing method and device
CN109857506B (en) Method and device for realizing guide information, electronic equipment and storage medium
CN110377341B (en) Method, device, medium and electronic equipment for monitoring no-response exception
CN107644075B (en) Method and device for collecting page information
CN110083417B (en) User interface response method and device
CN109634702B (en) Information prompting method and device, electronic equipment and readable medium
CN109815429B (en) Browser page closing processing method and device
CN113760503A (en) Task migration method and device, electronic equipment and computer readable medium
CN111367783B (en) Application program testing method and device and electronic equipment
CN110674050B (en) Memory out-of-range detection method and device, electronic equipment and computer storage medium
CN116302271A (en) Page display method and device and electronic equipment
CN115934378A (en) Service data processing method and device, electronic equipment and storage medium
CN109960659B (en) Method and device for detecting application program
CN111290812B (en) Display method, device, terminal and storage medium of application control
CN110377362B (en) Method, device, terminal and storage medium for cleaning application program
CN110427135B (en) Method, device, terminal and storage medium for determining application call
CN109614137B (en) Software version control method, device, equipment and medium
CN111381813B (en) Front-end page debugging method and device, computer equipment and storage medium
CN108471635B (en) Method and apparatus for connecting wireless access points
CN111949528A (en) Memory leak detection method and device, electronic equipment and storage medium
CN113296911A (en) Cluster calling method, cluster calling device, electronic equipment and readable storage medium
CN110633566A (en) Intrusion detection method, device, terminal equipment and medium
CN111625326A (en) Task pipeline execution method and device and electronic equipment
CN110471714B (en) Method, device, terminal and storage medium for controlling application starting
CN111324386A (en) Method and device for starting personal application program, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20210719

Address after: 200433 no.465 Guohe Road, Yangpu District, Shanghai

Patentee after: Shanghai suixun Electronic Technology Co.,Ltd.

Address before: 300000 Tianjin Binhai High-tech Zone Binhai Science Park, No. 39, No. 6 High-tech Road, 9-3-401

Patentee before: TIANJIN BYTEDANCE TECHNOLOGY Co.,Ltd.