Page zooming state detection method and device and nonvolatile storage medium
By obtaining the difference in device pixel and layout pixel coordinates of the cursor on the display screen and web page, combining window adjustment and mouse movement event monitoring, the problem of inaccurate web page scaling status detection in the prior art is solved, and high compatibility and accurate detection on different browsers and devices are achieved.
Patent Information
- Application Number
- CN202510486219.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-08-12
AI Technical Summary
The existing technology cannot effectively detect the scaling status of web pages, resulting in developers having to write redundant code to adapt to different web pages, and lacking a unified and compatible solution.
By obtaining the device pixel and layout pixel coordinates of the cursor on the display screen and web page, calculate the coordinate difference, use the difference value to determine whether the web page is zoomed, combine window adjustment and mouse movement event monitoring, set threshold filtering error judgment.
It achieves good compatibility and consistency on different browsers and devices, improves the accuracy of web page scaling status detection, provides unified detection methods, and improves the fluency of user experience.
Smart Images

Figure CN120469604A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a page zoom state detection method, device, and non-volatile storage medium. Background Art
[0002] Currently, page zoom status detection technology faces multiple challenges, mainly reflected in the lack of a unified and well-compatible solution. Although users can improve the user experience by adjusting the display ratio of web pages through the zoom function of web pages such as browsers, existing detection methods cannot accurately identify zooming behavior. First, there are significant differences in the support and implementation of zooming on different web pages, which requires developers to write redundant code to adapt to each web page. Secondly, although some modern web pages provide APIs such as visual viewport to obtain the current zoom ratio, these APIs are not unified and lack a widely compatible standardized solution, which limits developers in implementing zoom detection.
[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0004] The embodiments of the present invention provide a method, device, and non-volatile storage medium for detecting the zoom status of a page, so as to at least solve the technical problem that the prior art cannot effectively detect the zoom status of a web page.
[0005] According to one aspect of an embodiment of the present invention, a method for detecting a page zoom state is provided, comprising: obtaining first device pixel coordinates of a cursor relative to a display screen, and first layout pixel coordinates of the cursor relative to a target web page; determining a first difference between the first device pixel coordinates and the first layout pixel coordinates; obtaining second device pixel coordinates of the cursor relative to the display screen, and second layout pixel coordinates of the cursor relative to the target web page; determining a second difference between the second device pixel coordinates and the second layout pixel coordinates; and determining whether the target web page is zoomed based on a comparison result between the second difference and the first difference.
[0006] Optionally, the first device pixel coordinates are determined based on a coordinate system of a display screen resolution, and are used to describe a first coordinate of a cursor relative to the display screen; the first layout pixel coordinates are determined based on a coordinate system of a web page layout, and are used to describe a first coordinate of a cursor relative to a target web page.
[0007] Optionally, obtain the second device pixel coordinates of the cursor relative to the display screen, and the second layout pixel coordinates of the cursor relative to the target web page: detect and record the mobile device pixel coordinates of the cursor relative to the display screen in real time; obtain the second device pixel coordinates of the cursor relative to the display screen, and the second layout pixel coordinates of the cursor relative to the target web page based on the mobile device pixel coordinates.
[0008] Optionally, based on the mobile device pixel coordinates, the second device pixel coordinates of the cursor relative to the display screen and the second layout pixel coordinates of the cursor relative to the target web page are obtained: a third difference between the mobile device pixel coordinates and the adjacent previous recorded mobile device pixel coordinates is determined in real time; when the third difference is greater than a predetermined first threshold, the second device pixel coordinates of the cursor relative to the display screen and the second layout pixel coordinates of the cursor relative to the target web page are obtained.
[0009] Optionally, determining whether the target web page is scaled based on a comparison result between the second difference and the first difference includes: determining that the target web page is scaled down if the difference between the second difference and the first difference is greater than a predetermined second threshold; and determining that the target web page is not scaled down if the difference between the second difference and the first difference is less than or equal to the predetermined second threshold.
[0010] Optionally, determining whether the target webpage is zoomed in or out based on a comparison result between the second difference and the first difference includes: determining that the target webpage is zoomed in if the difference between the second difference and the first difference is greater than a predetermined third threshold; and determining that the target webpage is not zoomed in if the difference between the second difference and the first difference is less than or equal to the predetermined third threshold.
[0011] According to another aspect of an embodiment of the present invention, a page zoom state detection device is provided, comprising: a first acquisition module, configured to acquire first device pixel coordinates of a cursor relative to a display screen, and first layout pixel coordinates of the cursor relative to a target web page; a first determination module, configured to determine a first difference between the first device pixel coordinates and the first layout pixel coordinates; a second acquisition module, configured to acquire second device pixel coordinates of the cursor relative to the display screen, and second layout pixel coordinates of the cursor relative to the target web page; a second determination module, configured to determine a second difference between the second device pixel coordinates and the second layout pixel coordinates; and a third determination module, configured to determine whether the target web page is zoomed based on a comparison result between the second difference and the first difference.
[0012] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided. The non-volatile storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing any one of the page zoom state detection methods.
[0013] According to another aspect of an embodiment of the present invention, an electronic device is provided, comprising: one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement any one of the page zoom state detection methods.
[0014] According to yet another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program. When the computer program is executed by a processor, any one of the above-mentioned methods for detecting page zoom status is implemented.
[0015] In an embodiment of the present invention, a method is provided by obtaining first device pixel coordinates of a cursor relative to a display screen and first layout pixel coordinates of the cursor relative to a target web page; determining a first difference between the first device pixel coordinates and the first layout pixel coordinates; obtaining second device pixel coordinates of the cursor relative to the display screen and second layout pixel coordinates of the cursor relative to the target web page; determining a second difference between the second device pixel coordinates and the second layout pixel coordinates; and determining whether the target web page is scaled based on a comparison result between the second difference and the first difference. This method combines window adjustment monitoring with mouse movement event monitoring, and utilizes coordinate difference calculation to intelligently determine whether the page is scaled, thereby resolving the technical problem of the prior art being unable to effectively detect the scaled state of a web page, thereby achieving the technical effect of improving the accuracy of detecting the scaled state of a web page. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0017] Figure 1 is a flow chart of a page zoom status detection method provided by an embodiment of the present invention;
[0018] Figure 2 is a schematic diagram of a page zoom state detection device provided by an embodiment of the present invention;
[0019] Figure 3 is a schematic diagram of an electronic device provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0020] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0021] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0022] For ease of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0023] Page zooming: refers to the user adjusting the display ratio of a web page through the browser's zoom function to change the size and layout of the web page content. This operation usually includes zooming in or out of the page so that users can better view text, pictures and other elements. On a technical level, page zooming affects the relationship between layout pixels (CSS pixels) and device pixels, resulting in changes in the rendered size and position of elements and the coordinate values of mouse events. Page zooming can be achieved through the browser menu, keyboard shortcuts (such as Ctrl+"+" or Ctrl+"-"), and touch gestures (such as pinching).
[0024] Layout pixels (CSS pixels) and device pixels: Device pixels are based on the physical screen resolution, while layout pixels are based on the layout of web pages such as browsers. When the page is manually scaled, the layout pixels will change due to the scale.
[0025] According to an embodiment of the present invention, a method embodiment for detecting a page zoom state is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0026] Figure 1FIG. 1 is a flow chart of a method for detecting page zoom status according to an embodiment of the present invention. Figure 1 As shown, the method includes the following steps:
[0027] Step S102, obtaining a first device pixel coordinate of the cursor relative to the display screen, and a first layout pixel coordinate of the cursor relative to the target webpage;
[0028] In this step, before the detection starts, the first device pixel coordinates of the cursor are obtained, that is, the initial position of the cursor (or touch point) on the physical screen of the device is obtained, and the first layout pixel coordinates of the cursor are obtained, that is, the initial position of the cursor (or touch point) on the web page content is obtained.
[0029] In an optional embodiment, the first device pixel coordinates are determined based on the coordinate system of the display screen resolution, and are used to describe the first coordinates of the cursor relative to the display screen; the first layout pixel coordinates are determined based on the coordinate system of the web page layout, and are used to describe the first coordinates of the cursor relative to the target web page.
[0030] Optionally, the first device pixel coordinates provide the initial, precise physical position of the cursor on the display screen. These coordinates remain constant regardless of page zoom, reflecting the actual screen resolution. The first layout pixel coordinates represent the initial position of the cursor on the web page content. The layout pixel coordinates change as the page zoom level changes.
[0031] Step S104, determining a first difference between the first device pixel coordinates and the first layout pixel coordinates;
[0032] In this step, before detection begins, the cursor's first device pixel coordinates relative to the display screen and its first layout pixel coordinates relative to the target web page are subtracted to obtain a first difference. This first difference serves as a benchmark for determining whether the page has been scaled. Specifically, when a web page is manually scaled, the layout pixel coordinates will change because scaling changes the size and position of web page elements, but the device pixel coordinates remain unchanged because they are based on the physical resolution of the screen. Before detection begins, the first difference between the device pixel coordinates and the layout pixel coordinates is determined. When the web page is zoomed in or out, the difference between the device pixel coordinates and the layout pixel coordinates will change. When the difference exceeds a predetermined threshold, it can be determined that the web page has been scaled.
[0033] Step S106 , obtaining a second device pixel coordinate of the cursor relative to the display screen, and a second layout pixel coordinate of the cursor relative to the target webpage;
[0034] In this step, after the detection starts, the second device pixel coordinates of the cursor are obtained in real time, that is, the position of the cursor (or touch point) after moving on the physical screen of the device is obtained, and the second layout pixel coordinates of the cursor are obtained in real time, that is, the position of the cursor (or touch point) after moving on the web page content is obtained in real time.
[0035] In an optional embodiment, the second device pixel coordinates of the cursor relative to the display screen and the second layout pixel coordinates of the cursor relative to the target web page are obtained: the mobile device pixel coordinates of the cursor relative to the display screen are detected and recorded in real time; based on the mobile device pixel coordinates, the second device pixel coordinates of the cursor relative to the display screen and the second layout pixel coordinates of the cursor relative to the target web page are obtained.
[0036] Optionally, the system obtains the latest device pixel coordinates of the cursor on the screen in real time by monitoring user operations (such as mouse movement or touch screen sliding). Based on the real-time acquired device pixel coordinates, the system will further update the cursor position information in the two coordinate systems. For example, when the mouse moves for the first time, the new second device pixel coordinates are calculated, that is, the latest actual physical position of the cursor on the screen; at the same time, the second layout pixel coordinates of the cursor on the target web page are obtained, reflecting the current relative position of the cursor in the web page content. This process ensures that the system can simultaneously track the precise position of the cursor on the physical screen and in the web page content, providing an accurate data basis for subsequent difference calculations and judgments of the page zoom status.
[0037] In an optional embodiment, the second device pixel coordinates of the cursor relative to the display screen and the second layout pixel coordinates of the cursor relative to the target web page are obtained: the mobile device pixel coordinates of the cursor relative to the display screen are detected and recorded in real time; based on the mobile device pixel coordinates, the second device pixel coordinates of the cursor relative to the display screen and the second layout pixel coordinates of the cursor relative to the target web page are obtained.
[0038] Optionally, the system obtains the latest device pixel coordinates of the cursor on the screen in real time by monitoring user operations (such as mouse movement or touch screen sliding). Based on the real-time acquired device pixel coordinates, the system will further update the cursor position information in the two coordinate systems. For example, when the mouse moves for the first time, the new second device pixel coordinates are calculated, that is, the latest actual physical position of the cursor on the screen; at the same time, the second layout pixel coordinates of the cursor on the target web page are obtained, reflecting the current relative position of the cursor in the web page content. This process ensures that the system can simultaneously track the precise position of the cursor on the physical screen and in the web page content, providing an accurate data basis for subsequent difference calculations and judgments of the page zoom status.
[0039] Step S108, determining a second difference between the second device pixel coordinates and the second layout pixel coordinates;
[0040] In this step, the cursor is detected in real time. Each time a detection is performed, the device pixel coordinates of the cursor relative to the display screen obtained by the real-time detection are subtracted from the layout pixel coordinates of the cursor relative to the target web page to obtain a second difference value.
[0041] Step S110 : determining whether the target webpage is zoomed based on a comparison result between the second difference and the first difference.
[0042] In this step, by comparing the changes between the second difference and the first difference, if the change exceeds the preset threshold, this indicates that the relationship between the device pixel coordinates and the layout pixel coordinates has changed significantly. This change cannot be explained solely by the physical movement of the cursor, but is the result of page zooming. Through this series of calculations and comparisons, the manual zoom status of the page can be monitored in real time. Even if the user's operations are frequent and complex, it can be accurately determined whether the page is zoomed or not, thereby providing users with a smoother and more accurate zooming experience. At the same time, this method has good compatibility and consistency across different browsers and devices, providing developers with a unified technical means of detecting page zooming.
[0043] In an optional embodiment, determining whether the target web page is scaled based on a comparison result between the second difference and the first difference includes: determining that the target web page is scaled down if the difference between the second difference and the first difference is greater than a predetermined second threshold; and determining that the target web page is not scaled down if the difference between the second difference and the first difference is less than or equal to the predetermined second threshold.
[0044] Optionally, the system continuously records the coordinate values of the cursor position in the device pixel coordinate system (reflecting the physical screen resolution) and the layout pixel coordinate system (related to the webpage content display) and calculates the difference between the two. When the user zooms out, the cursor coordinate value in the layout pixel coordinate system will increase relatively (because the page content is shrinking, the value represented by the same physical position in the layout coordinate system becomes larger), while the device pixel coordinates remain unchanged. In this case, the difference between the new second difference and the previously recorded first difference will increase significantly. If the absolute value of this difference exceeds a pre-set second threshold, the system will determine that the target webpage has been shrunk. Similarly, the system will calculate the change between the new and old difference values. If the change in the cursor position is caused by the user panning the page, rather than zooming in and out, the difference between the second difference and the first difference should remain within a small range. If the absolute value of this difference is less than or equal to the second threshold, the system will assume that the page has not been shrunk, that is, the change in the current cursor position is caused by panning the cursor, rather than zooming in and out.
[0045] In an optional embodiment, determining whether the target web page is zoomed based on a comparison result between the second difference and the first difference includes: determining that the target web page is zoomed in if the difference between the second difference and the first difference is greater than a predetermined third threshold; and determining that the target web page is not zoomed in if the difference between the second difference and the first difference is less than or equal to the predetermined third threshold.
[0046] Optionally, when a user zooms in on a web page, the coordinate value of the cursor in the layout pixel coordinate system will decrease relatively (because the page content is enlarged, the value represented by the same physical position in the layout coordinates becomes smaller), while the device pixel coordinate value remains unchanged. If this difference exceeds a pre-set third threshold, the system will determine that the target web page has been enlarged. The setting of this threshold can filter out false positives caused by slight movements of the cursor, ensuring that the corresponding detection result is triggered only when the page is significantly enlarged. In contrast to the above situation, if the change in the cursor position is caused by slight movements of the user on the page or an operation that does not involve page zooming, then the difference between the second difference and the first difference should remain within a small range. If this difference is less than or equal to the third threshold, then the system will assume that the page has not been enlarged, that is, the change in the cursor position is caused by other non-zooming operations. This setting can effectively avoid false positives and improve the accuracy and stability of system detection.
[0047] By comparing the second difference with the first difference, determining whether the target webpage is scaled, determining the first difference between the first device pixel coordinates and the first layout pixel coordinates; obtaining the second device pixel coordinates of the cursor relative to the display screen, and the second layout pixel coordinates of the cursor relative to the target webpage; determining the second difference between the second device pixel coordinates and the second layout pixel coordinates; obtaining the first device pixel coordinates of the cursor relative to the display screen, and the first layout pixel coordinates of the cursor relative to the target webpage, the technical problem of the prior art being unable to effectively detect the scaled state of a webpage is solved, thereby achieving the technical effect of improving the accuracy of detecting the scaled state of a webpage.
[0048] Based on the above embodiments and optional embodiments, the present invention proposes an optional implementation manner.
[0049] Step S1, setting the basic state and threshold.
[0050] Initialize "lastDifferenceX" and "lastDifferenceY" to "null" to indicate that no calculation has been performed, providing a clear starting point for subsequent difference calculations, where "lastDifferenceX" represents the X-axis value of the first difference and "lastDifferenceY" represents the Y-axis value of the first difference.
[0051] The default value of "threshold" is 0.5, which represents the threshold (second or third threshold) used to determine the difference change. This value setting ensures that a significant change is only considered when the absolute value of the current difference with the previous difference exceeds this threshold.
[0052] The "movementThreshold" (first threshold) is set to 3 to ignore small movements of the cursor, effectively preventing misjudgment caused by small movements that are not noticed by the user.
[0053] "isResizing" is a Boolean variable that indicates whether the current window is being resized. The initial value is "false" and is used for subsequent logic judgment.
[0054] "historyLength" indicates the length of the difference history record. If it is set to 5, a maximum of 5 difference records will be retained to ensure the validity of historical data.
[0055] The "differenceHistor array" is used to store the difference records of each mouse movement event for subsequent trend analysis.
[0056] Step S2: monitoring the window size change of the web page to eliminate invalid mouse movement interference generated when the window is adjusted.
[0057] Window resizing typically refers to resizing a browser or application window, while zooming refers to enlarging or reducing the content displayed within a window while maintaining the same size. In a web browser, users can zoom in or out by scrolling the mouse wheel, using keyboard controls (such as Ctrl+, Ctrl-), or using pinch gestures on a touchscreen. Zooming changes the visual size of the page content, not just the physical size of the window. Zooming affects the visual layout, font size, and size of images and elements on the page, but the window's border size remains unchanged.
[0058] Use "window.addEventListener('resize')" to monitor window size changes: When the window size changes, set "isResizing" to "true" and reset "lastDifferenceX", "lastDifferenceY", and "differenceHistory". This ensures that invalid mouse movement calculations are not generated during window resizing, improving calculation accuracy. Use "setTimeout" to handle the end of window resizing: set a delay time (300 milliseconds) and reset "isResizing" to "false" after determining that the window resizing is complete.
[0059] Step S3: monitor mouse movement events and capture user interactions in real time to determine the page status.
[0060] Use "window.addEventListener(mousemove)" to monitor mouse movement events: When the mouse moves, first check the "isResizing" state. If the window is being resized, terminate the current event processing to avoid unnecessary calculations.
[0061] Step S4: Calculate the difference between the device pixel coordinates and the layout pixel coordinates to analyze changes in the web page.
[0062] Calculate a first difference between a first device pixel coordinate of the current cursor relative to the display screen and a first layout pixel coordinate relative to the target webpage, where both the first device pixel coordinate and the first layout pixel coordinate are two-dimensional coordinates, and the calculation formula is:
[0063] currentDifferenceX=event.screenX-event.clientX
[0064] currentDifferenceY=event.screenY-event.clientY
[0065] Among them, "currentDifferenceX" represents the difference between the first device pixel coordinates and the first layout pixel coordinates on the X axis, and "currentDifferenceY" represents the difference between the first device pixel coordinates and the first layout pixel coordinates on the Y axis. "event.screenX" represents the X-axis value of the first device pixel coordinates, and "event.screenY" represents the Y-axis value of the first device pixel coordinates. "event.clientX" represents the X-axis value of the first layout pixel coordinates, and "event.clientY" represents the Y-axis value of the first layout pixel coordinates. The calculation of this difference is intended to capture the change in the cursor position under the initial page zoom state, providing a basis for subsequent analysis. The careful consideration in this step ensures the uniformity of coordinates in different browser environments to avoid misjudgments caused by zooming.
[0066] Step S5: filtering small movements of the cursor to prevent invalid data from affecting the analysis results.
[0067] Check whether the actual movement distance of the mouse is less than the set "movementThreshold" (first threshold). If the movement amplitude is less than the third threshold, no subsequent difference judgment is performed to avoid misjudgment.
[0068] Step S6: Establish a benchmark for subsequent comparison.
[0069] If "lastDifferenceX" or "lastDifferenceY" is still "null", it means that no valid calculation has been performed. In this case, the current difference value is stored as the previous difference. The change between the current difference and the previous difference is recorded and added to "differenceHistory". The history length must not exceed "historyLength". If the history length exceeds "historyLength", the oldest difference value is removed.
[0070] Step S7: Analyze the data to draw conclusions.
[0071] Traverse the "differenceHistory" array and check whether there is a significant change. If there is a significant change, output "The page is zoomed", otherwise output "The page is not zoomed". At the end of the event processing, update "lastDifferenceX" and "lastDifferenceY" for next use.
[0072] The above optional implementation achieves at least the following: This method combines window adjustment monitoring with mouse motion event monitoring, utilizing coordinate difference calculation to intelligently determine whether a page has been scaled. By setting appropriate thresholds and managing historical records, this logic effectively prevents misjudgments and improves the user experience's fluidity and interactive accuracy. The overall design emphasizes accuracy and effectiveness, ensuring precise capture and analysis of user interaction states.
[0073] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0074] In this embodiment, a page zoom state detection device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation methods. The details that have been described will not be repeated here. As used below, the terms "module" and "device" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and conceivable.
[0075] According to an embodiment of the present invention, there is also provided an embodiment of a device for implementing a method for detecting a page zoom state. Figure 2 is a schematic diagram of a device for detecting page zoom status according to an embodiment of the present invention. Figure 2 As shown, the page zoom state detection device includes a first acquisition module 21, a first determination module 22, a second acquisition module 23, a second determination module 24, and a third determination module 25. The device is described below.
[0076] A first acquisition module 21 is configured to acquire a first device pixel coordinate of a cursor relative to a display screen, and a first layout pixel coordinate of the cursor relative to a target webpage;
[0077] A first determining module 22, connected to the first acquiring module 21, is configured to determine a first difference between the first device pixel coordinates and the first layout pixel coordinates;
[0078] A second acquisition module 23, connected to the first determination module 22, is used to obtain a second device pixel coordinate of the cursor relative to the display screen, and a second layout pixel coordinate of the cursor relative to the target webpage;
[0079] A second determining module 24, connected to the second acquiring module 23, is configured to determine a second difference between the second device pixel coordinates and the second layout pixel coordinates;
[0080] The third determining module 25 is connected to the second determining module 24 and is configured to determine whether the target webpage is zoomed or not according to a comparison result between the second difference and the first difference.
[0081] In a page zoom state detection device provided by an embodiment of the present invention, a first acquisition module is provided for acquiring first device pixel coordinates of a cursor relative to a display screen and first layout pixel coordinates of the cursor relative to a target web page; a first determination module is provided for determining a first difference between the first device pixel coordinates and the first layout pixel coordinates; a second acquisition module is provided for acquiring second device pixel coordinates of the cursor relative to the display screen and second layout pixel coordinates of the cursor relative to the target web page; a second determination module is provided for determining a second difference between the second device pixel coordinates and the second layout pixel coordinates; and a third determination module is provided for determining whether the target web page is zoomed based on a comparison result between the second difference and the first difference. This solves the technical problem that the prior art cannot effectively detect the zoom state of a web page, thereby achieving the technical effect of improving the accuracy of detecting the zoom state of a web page.
[0082] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0083] It should be noted that the first acquisition module 21, first determination module 22, second acquisition module 23, second determination module 24, and third determination module 25 described above correspond to steps S102 to S110 in the embodiment. The examples and application scenarios implemented by these modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiment. It should be noted that these modules, as part of the device, can be run on a computer terminal.
[0084] It should be noted that the optional or preferred implementation of this embodiment can be found in the relevant description in the embodiment, which will not be repeated here.
[0085] The above-mentioned page zoom status detection device can also include a processor and a memory. The first acquisition module 21, the first determination module 22, the second acquisition module 23, the second determination module 24, the third determination module 25, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize the corresponding functions.
[0086] The processor includes a kernel, which retrieves the corresponding program unit from memory. There can be one or more kernels. Memory may include non-permanent memory in a computer-readable medium, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory includes at least one memory chip.
[0087] An embodiment of the present invention provides a non-volatile storage medium having a program stored thereon, which, when executed by a processor, implements the following steps: obtaining first device pixel coordinates of a cursor relative to a display screen, and first layout pixel coordinates of the cursor relative to a target web page; determining a first difference between the first device pixel coordinates and the first layout pixel coordinates; obtaining second device pixel coordinates of the cursor relative to the display screen, and second layout pixel coordinates of the cursor relative to the target web page; determining a second difference between the second device pixel coordinates and the second layout pixel coordinates; and determining whether the target web page is scaled based on a comparison result between the second difference and the first difference.
[0088] like Figure 3 As shown, an embodiment of the present invention provides an electronic device, the electronic device 10 includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: the memory is used to store a computer program, wherein, when the computer program is executed by the processor, the processor implements the above-mentioned acquisition of the first device pixel coordinates of the cursor relative to the display screen, and the first layout pixel coordinates of the cursor relative to the target web page; determining a first difference between the first device pixel coordinates and the first layout pixel coordinates; acquiring the second device pixel coordinates of the cursor relative to the display screen, and the second layout pixel coordinates of the cursor relative to the target web page; determining a second difference between the second device pixel coordinates and the second layout pixel coordinates; and determining whether the target web page is scaled based on a comparison result between the second difference and the first difference. The device in this article can be a server, a PC, etc.
[0089] The present invention also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program initialized with the following method steps: computer instructions are executed by a processor to obtain the above-mentioned first device pixel coordinates of the cursor relative to the display screen, and the first layout pixel coordinates of the cursor relative to the target web page; determine a first difference between the first device pixel coordinates and the first layout pixel coordinates; obtain the second device pixel coordinates of the cursor relative to the display screen, and the second layout pixel coordinates of the cursor relative to the target web page; determine a second difference between the second device pixel coordinates and the second layout pixel coordinates; and determine whether the target web page is scaled based on a comparison result between the second difference and the first difference.
[0090] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0091] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0092] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0093] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0094] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0095] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0096] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0097] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0098] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0099] The above are merely embodiments of the present invention and are not intended to limit the present invention. It will be apparent to those skilled in the art that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.
Claims
1. A page zoom state detection method, characterized in that: include: Obtaining a first device pixel coordinate of a cursor relative to a display screen, and a first layout pixel coordinate of the cursor relative to a target webpage; determining a first difference between the first device pixel coordinate and the first layout pixel coordinate; Obtaining a second device pixel coordinate of the cursor relative to the display screen, and a second layout pixel coordinate of the cursor relative to the target webpage; determining a second difference between the second device pixel coordinate and the second layout pixel coordinate; According to a comparison result between the second difference value and the first difference value, it is determined whether the target webpage is zoomed.
2. The method according to claim 1, characterized in that The first device pixel coordinates are determined based on a coordinate system of a display screen resolution and are used to describe a first coordinate of the cursor relative to the display screen; The first layout pixel coordinates are determined based on a coordinate system of a webpage layout, and are used to describe a first coordinate of the cursor relative to the target webpage.
3. The method according to claim 1, characterized in that The obtaining of the second device pixel coordinates of the cursor relative to the display screen and the second layout pixel coordinates of the cursor relative to the target webpage: Detecting and recording the mobile device pixel coordinates of the cursor relative to the display screen in real time; According to the mobile device pixel coordinates, a second device pixel coordinate of the cursor relative to the display screen and a second layout pixel coordinate of the cursor relative to the target webpage are obtained.
4. The method according to claim 3, characterized in that The second device pixel coordinates of the cursor relative to the display screen and the second layout pixel coordinates of the cursor relative to the target webpage are obtained according to the pixel coordinates of the mobile device: Determining in real time a third difference between the pixel coordinates of the mobile device and the pixel coordinates of the mobile device recorded at a previous time; When the third difference is greater than a predetermined first threshold, a second device pixel coordinate of the cursor relative to the display screen and a second layout pixel coordinate of the cursor relative to the target webpage are obtained.
5. The method according to claim 1, wherein The determining whether the target webpage is zoomed according to the comparison result between the second difference and the first difference includes: In a case where the difference between the second difference and the first difference is greater than a predetermined second threshold, determining that the target webpage is zoomed out; If the difference between the second difference and the first difference is less than or equal to the predetermined second threshold, it is determined that the target webpage is not zoomed out.
6. The method according to claim 1, wherein The determining whether the target webpage is zoomed according to the comparison result between the second difference and the first difference includes: In a case where the difference between the second difference and the first difference is greater than a predetermined third threshold, determining that the target webpage is to be enlarged; If the difference between the second difference and the first difference is less than or equal to the predetermined third threshold, it is determined that the target webpage is not enlarged.
7. A device for detecting page zoom status, characterized in that: include: A first acquisition module is configured to acquire a first device pixel coordinate of a cursor relative to a display screen, and a first layout pixel coordinate of the cursor relative to a target webpage; a first determining module, configured to determine a first difference between the first device pixel coordinates and the first layout pixel coordinates; A second acquisition module is configured to acquire a second device pixel coordinate of the cursor relative to the display screen, and a second layout pixel coordinate of the cursor relative to the target webpage; a second determining module, configured to determine a second difference between the second device pixel coordinates and the second layout pixel coordinates; The third determining module is configured to determine whether the target webpage is zoomed or not according to a comparison result between the second difference and the first difference.
8. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executed by the page zoom state detection method according to any one of claims 1 to 6.
9. An electronic device, characterized in that: include: One or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the page zoom state detection method described in any one of claims 1 to 6.
10. A computer program product comprising computer instructions, characterized in that The computer instructions are executed by a processor to implement the page zoom state detection method according to any one of claims 1 to 6.