Webpage zooming method and device, storage medium and electronic equipment
By rewriting the size transformation function in the web page scaling method, the problem of incompatibility between the Zoom method and the size transformation function is solved, accurate scaling and display of web page elements is achieved, and the user experience is improved.
Patent Information
- Application Number
- CN202410910581.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-07-08
AI Technical Summary
Among existing web page scaling methods, the Zoom method is not compatible with the size transformation function used to determine the position and size of elements relative to the viewport, resulting in problems such as overlapping and misalignment of element display, which affects the user experience.
By determining the initial predicted size and target size of the web page scaling, the size transformation function is rewritten and the size and position of the web page elements are recalculated to ensure accurate display of the scaled elements.
It effectively solves the problem of inaccurate element display and improves the adaptability and user experience of web pages in different device and browser environments.
Smart Images

Figure CN118839079A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and more particularly to a web page zooming method, device, storage medium and electronic device. Background Art
[0002] Due to the different types of devices used by users, when displaying a web page, it is usually necessary to scale the web page so that the content of the web page can be presented to the user in the best display method. Generally speaking, developers can design web pages that can adapt to multiple terminal versions during development.
[0003] However, in the actual development process, due to time and resource constraints, developers may only design a terminal version of the web page. In this case, the existing web page needs to be quickly modified to adapt to different browser window sizes. Generally, the Zoom method in CSS (Cascading Style Sheets, CSS) 3 can be used to adjust the element zoom ratio and change the web page display effect, so as to achieve flexible layout and zoom of web page elements, so that the web page can be displayed normally on various devices and provide the best user experience.
[0004] However, there is an incompatibility problem between the Zoom method and the size transformation function used to determine the position and size of various elements relative to the viewport. In other words, after the elements on the page are scaled by the Zoom method, the size of the elements and the position relative to the viewport returned by the size transformation function may be inaccurate. This may cause the elements displayed on the page to overlap with each other, and the elements to be misplaced when the user scrolls the page, resulting in a poor user experience.
[0005] Based on this, this specification provides a web page zooming method. Summary of the invention
[0006] The present specification provides a webpage zooming method, device, storage medium and electronic device to partially solve the above-mentioned problems existing in the prior art.
[0007] This manual adopts the following technical solutions:
[0008] This specification provides a webpage zooming method, the method comprising:
[0009] Determine the web page to be scaled, and the size transformation function used to transform the elements in the web page;
[0010] Determine a size that can be obtained by transforming the element in the webpage through the size transformation function as an initial predicted size;
[0011] Rewriting the size transformation function according to the initial predicted size and the target size, so that the size obtained by transforming the element in the webpage according to the rewritten size transformation function is the target size;
[0012] Determine the webpage zoom ratio of the webpage; and zoom the webpage according to the webpage zoom ratio and the rewritten size transformation function.
[0013] Optionally, determining the webpage to be scaled specifically includes:
[0014] In response to a web page access operation by a user, obtaining a uniform resource locator of the web page;
[0015] According to the uniform resource locator, determining whether the webpage is a webpage to be scaled;
[0016] If yes, determining the webpage visited by the user as the webpage to be zoomed;
[0017] If not, the webpage visited by the user is determined as a webpage that is not to be scaled, and a size conversion function provided by the browser where the webpage is located is called through a Proxy agent.
[0018] Optionally, judging whether the webpage is a webpage to be scaled according to the uniform resource locator specifically includes:
[0019] Determining whether the value of the preset flag bit in the uniform resource locator is a preset value;
[0020] If yes, determining the webpage visited by the user as the webpage to be zoomed;
[0021] If not, the webpage visited by the user is determined as a webpage that is not to be scaled.
[0022] Optionally, the size transformation function includes a getBoundingClientRec function;
[0023] According to the initial predicted size and the target size, the size conversion function is rewritten, specifically including:
[0024] According to the initial predicted size and the target size, the getBoundingClientRect function is rewritten through a Proxy agent, and the initial predicted size is negatively correlated with the target size.
[0025] Optionally, determining the webpage zoom ratio of the webpage specifically includes:
[0026] Obtaining the window width of the browser where the webpage is located;
[0027] When the browser window width is smaller than a first preset size, determining the webpage zoom ratio as a first zoom ratio;
[0028] When the browser window width is greater than a second preset size, the webpage zoom ratio is determined to be a second zoom ratio;
[0029] When the window width of the browser is not less than the first preset size and not greater than the second preset size, the webpage zoom ratio is determined according to a preset proportional relationship and the window width of the browser, wherein the preset proportional relationship includes a positive correlation between the webpage zoom ratio and the window width of the browser.
[0030] Optionally, scaling the webpage according to the webpage scaling ratio and the rewritten size transformation function specifically includes:
[0031] Determining the initial size of each element in the web page;
[0032] For each element in the webpage, determining a first predicted size of the element according to the initial size of the element and the webpage zoom ratio by using the size transformation function;
[0033] Determining a second predicted size of the element according to the first predicted size and the webpage zoom ratio by using the rewritten size transformation function;
[0034] The webpage is scaled using a Zoom method according to the second predicted size of each element in the webpage.
[0035] Optionally, the method further comprises:
[0036] Determine whether the window width of the browser where the webpage is located has changed;
[0037] If yes, re-determine the zoom ratio of the webpage;
[0038] The web page is scaled according to the re-determined web page scaling ratio and the rewritten size conversion function.
[0039] Optionally, determining whether the window width of the browser where the webpage is located has changed specifically includes:
[0040] By monitoring the size adjustment event, the window width of the browser where the web page is located is obtained in real time;
[0041] According to the browser window width acquired in real time, it is determined whether the window width of the browser where the webpage is located has changed.
[0042] This specification provides a webpage zooming device, the device comprising:
[0043] A web page determination module, used to determine the web page to be scaled, and a size transformation function used to transform the elements in the web page;
[0044] A size determination module, used to determine a size that can be obtained by transforming the element in the web page through the size transformation function as an initial predicted size;
[0045] A rewriting module, used to rewrite the size transformation function according to the initial predicted size and the target size, so that the size obtained by transforming the element in the web page according to the rewritten size transformation function is the target size;
[0046] The zoom module is used to determine the webpage zoom ratio of the webpage; and zoom the webpage according to the webpage zoom ratio and the rewritten size conversion function.
[0047] Optionally, the web page determination module is specifically used to, in response to a user's web page access operation, obtain a uniform resource locator of a web page; determine, based on the uniform resource locator, whether the web page is a web page to be scaled; if so, determine the web page accessed by the user as a web page to be scaled; if not, determine the web page accessed by the user as a web page not to be scaled, and call a size conversion function provided by the browser where the web page is located through a Proxy agent.
[0048] Optionally, the web page determination module is specifically used to determine whether the value of the preset flag in the uniform resource locator is a preset value; if so, determine the web page visited by the user as a web page to be scaled; if not, determine the web page visited by the user as a web page not to be scaled.
[0049] Optionally, the size transformation function includes a getBoundingClientRec function; the rewriting module is specifically used to rewrite the getBoundingClientRect function through a Proxy agent according to the initial predicted size and the target size, and the initial predicted size is negatively correlated with the target size.
[0050] Optionally, the zoom module is specifically used to obtain the window width of the browser where the web page is located; when the window width of the browser is less than a first preset size, determine the web page zoom ratio as a first zoom ratio; when the window width of the browser is greater than a second preset size, determine the web page zoom ratio as a second zoom ratio; when the window width of the browser is not less than the first preset size and not greater than the second preset size, determine the web page zoom ratio according to a preset proportional relationship and the window width of the browser, the preset proportional relationship including a positive correlation between the web page zoom ratio and the window width of the browser.
[0051] Optionally, the scaling module is specifically used to determine the initial size of each element in the web page; for each element in the web page, determine the first predicted size of the element according to the initial size of the element and the web page scaling ratio through the size transformation function; determine the second predicted size of the element according to the first predicted size and the web page scaling ratio through the rewritten size transformation function; and scale the web page through the Zoom method according to the second predicted sizes of each element in the web page.
[0052] Optionally, the device further comprises:
[0053] The monitoring module is used to determine whether the window width of the browser where the web page is located has changed; if so, re-determine the web page zoom ratio; and scale the web page according to the re-determined web page zoom ratio and the rewritten size conversion function.
[0054] Optionally, the monitoring module is specifically used to obtain the window width of the browser where the webpage is located in real time by monitoring the size adjustment event; and determine whether the window width of the browser where the webpage is located has changed according to the browser window width obtained in real time.
[0055] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the webpage zooming method when executing the program.
[0056] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0057] It can be seen from the web page zooming method provided in this specification that the method first determines the web page to be zoomed, and the size transformation function used to transform the elements in the web page. Then, the size that can be obtained by transforming the elements in the web page through the size transformation function is determined as the initial predicted size. According to the initial predicted size and the target size, the size transformation function is rewritten so that the size that can be obtained by transforming the elements in the web page according to the rewritten size transformation function is the target size. The web page zoom ratio of the web page is determined, and the web page is zoomed according to the web page zoom ratio and the rewritten size transformation function. By rewriting the size transformation function that is not compatible with the Zoom method so that the rewritten size transformation function can output the target size, the web page can adapt to various devices and display the web page content normally, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the drawings:
[0059] Figure 1 A schematic diagram of a flow chart of a web page zooming method provided in this specification;
[0060] Figure 2 Another web page zooming flow chart provided for this manual;
[0061] Figure 3 A schematic diagram of a webpage zooming device provided in this specification;
[0062] Figure 4 A method corresponding to the Figure 1 Schematic diagram of the structure of an electronic device. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0064] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0065] Figure 1 A schematic diagram of a webpage zooming method provided in this specification includes the following steps:
[0066] S100: Determine a web page to be scaled and a size transformation function for transforming elements in the web page.
[0067] In the process of web design, in order to make the web page adaptable to various display devices, such as computers, tablets, mobile phones and other terminals, multiple versions of web pages are usually designed. However, due to the limitations of development time and resources, developers may only design one version of the web page. In order to provide users with a better experience, the elements of the web page can be scaled by the Zoom method so that the content of the web page can be displayed normally to the user. However, due to the incompatibility problem between the Zoom method and the getBoundingClientRect function (size conversion function), the web page elements displayed to the user overlap and other problems occur, which reduces the user experience. Therefore, this manual provides a web page scaling method. The execution subject of this manual can be a computing device that can rewrite the size conversion function, such as a server, a personal computer (Personal Computer, PC), etc., and can also be other electronic devices with computing capabilities. This description says that there is no limitation on this. For the sake of convenience, this manual is described with the server as the execution subject.
[0068] Figure 2 Another web page zooming flow chart provided for this manual, such as Figure 2 shown.
[0069] Before scaling a web page, the server first determines whether the web page needs to be scaled, that is, determines the web page to be scaled.
[0070] Specifically, in response to the user's web page access operation, the uniform resource locator of the web page is obtained. According to the uniform resource locator, it is determined whether the web page is a web page to be scaled. If so, the web page accessed by the user is determined as a web page to be scaled. If not, the web page accessed by the user is determined as a web page not to be scaled, and a size conversion function provided by the browser where the web page is located is called through a proxy.
[0071] Of course, the size conversion function can also be called without using a Proxy proxy. The default calling method is used when the size conversion function is called later. The default calling method is the method used by the browser of the web page to call the size conversion function without any modification. This is because the web page does not need to be scaled. Therefore, when displaying the web page, the Zoom method does not need to be used. There is no problem of incompatibility between the Zoom method and the size conversion function. The position and size of various elements obtained by the size conversion function relative to the viewport are relatively accurate, and there is no overlap of web page elements displayed to the user.
[0072] Even if you don't scale the web page, you can still call the size change function provided by the browser where the web page is located through the Proxy proxy. This is because the Proxy proxy can unify all calls to the size change function in one place for management, which makes the code clearer and easier to maintain. If you need to process the size change function in the future, you only need to modify it in the Proxy proxy, without having to modify all places where the method is called. In addition, if a web page can run in multiple browser environments, you may encounter some browser compatibility issues. Through the Proxy proxy, you can handle the differences between different browsers in the Proxy proxy, so that the web page maintains consistent behavior in different environments.
[0073] After obtaining the web page to be scaled, a size transformation function for transforming elements in the web page can be obtained. The size transformation function can be used for subsequent rewriting operations, wherein the size transformation function includes a getBoundingClientRec function.
[0074] S102: Determine a size that can be obtained by transforming the element in the web page through the size transformation function as an initial predicted size.
[0075] Generally speaking, the server does not have the authority to directly modify the various functions contained in the browser itself, and if forced to modify it, it may undermine the security and stability of the browser environment. However, since the size conversion function contained in the browser itself does not match the Zoom method, the size of the element obtained by the size conversion function and the position relative to the browser window are inaccurate. Therefore, the size conversion function can be rewritten so that the size conversion function calculates the correct element result.
[0076] Then, the server may first determine the size that can be obtained by transforming the element in the web page through the size transformation function as the initial predicted size. That is, before rewriting the size transformation function, the size transformation function is first called normally, and the size transformation function is rewritten according to the calculation result of the size transformation function.
[0077] S104: rewriting the size transformation function according to the initial predicted size and the target size, so that the size obtained by transforming the element in the web page according to the rewritten size transformation function is the target size.
[0078] Specifically, the server can rewrite the getBoundingClientRect function through the Proxy agent according to the initial predicted size and the target size, and the initial predicted size is negatively correlated with the target size. For example, the web page zoom ratio is 0.5, the element size is 100*100, then the target size is 50*50, but the size obtained by the non-rewritten getBoundingClientRect function is 200*200. Therefore, it can be seen that the initial predicted size is negatively correlated with the target size. Assuming that y1 is =ax, y1 is the target size, it can be verified by calculation that y2 = (1 / a)x, y2 is the initial predicted size obtained by the non-rewritten getBoundingClientRect function. Therefore, the relationship between the target size and the initial predicted size is y1 = x 2 / y2.
[0079] The getBoundingClientRect function is rewritten by the Proxy because the Proxy provides the ability to dynamically modify the behavior of functions. It can dynamically decide whether to rewrite the function, how to rewrite the function, and when to rewrite the function according to different conditions or contexts. This flexibility allows the behavior of the function to be dynamically adjusted according to needs without modification, and in this way, the integrity of the original function can be maintained, avoiding the risks and side effects that may be caused by direct modifications to the original function.
[0080] S106: Determine a webpage zoom ratio of the webpage; and zoom the webpage according to the webpage zoom ratio and the rewritten size transformation function.
[0081] In one or more embodiments of the present specification, the web page zoom ratio is related to the window width of the browser. Therefore, when determining the web page zoom ratio, the window width of the browser where the web page is located can be obtained first. After that, the web page zoom ratio is determined according to the window width. Generally speaking, when the window width of the browser is less than the first preset size, the web page zoom ratio is determined as the first zoom ratio. When the window width of the browser is greater than the second preset size, the web page zoom ratio is determined as the second zoom ratio. When the window width of the browser is not less than the first preset size and not greater than the second preset size, the web page zoom ratio is determined according to the preset proportional relationship and the window width of the browser, and the preset proportional relationship includes that the web page zoom ratio is positively correlated with the window width of the browser. Among them, the first preset size, the first zoom ratio, the second preset size, the second zoom ratio and the preset proportional relationship can be set as needed, but the web page zoom ratio must be positively correlated with the window width.
[0082] For example, if the first preset size is 1280 and the second preset size is 1370, then the first zoom ratio may be 0.8 and the second zoom ratio may be 1. That is, when the window width of the browser is less than 1280, the webpage zoom ratio is 0.8, when the window width of the browser is greater than 1370, the webpage zoom ratio is 1, and when the window width of the browser is not less than 1280 and not greater than 1370, the wider the window width, the greater the webpage zoom ratio.
[0083] Afterwards, the server can use the CSS variables to call the Zoom method to scale the web page according to the zoom ratio of the web page and the rewritten size transformation function.
[0084] Specifically, the server first determines the initial size of each element in the webpage, and for each element in the webpage, determines the first predicted size of the element according to the initial size of the element and the zoom ratio of the webpage through the size conversion function. Determine the second predicted size of the element according to the first predicted size and the zoom ratio of the webpage through the rewritten size conversion function, and zoom the webpage through the Zoom method according to the second predicted size of each element in the webpage.
[0085] For example, if the initial size of the element is 100*100 and the webpage zoom ratio is 0.5, the first predicted size is 200, and the second predicted size determined according to the rewritten size conversion function and the first predicted size is 50. Then, the elements in the webpage can be zoomed according to the second predicted size of each element in the webpage through the Zoom method to obtain the zoomed elements, thus completing the zooming of the webpage.
[0086] based on Figure 1 The webpage zooming method shown in the figure first determines the webpage to be zoomed, and the size transformation function used to transform the elements in the webpage. Then, the size that can be obtained by transforming the elements in the webpage through the size transformation function is determined as the initial predicted size. According to the initial predicted size and the target size, the size transformation function is rewritten so that the size that can be obtained by transforming the elements in the webpage according to the rewritten size transformation function is the target size. The webpage zoom ratio of the webpage is determined, and the webpage is zoomed according to the webpage zoom ratio and the rewritten size transformation function. By rewriting the size transformation function that is not compatible with the Zoom method so that the rewritten size transformation function can output the target size, the webpage can adapt to various devices and display the webpage content normally, thereby improving the user experience.
[0087] For step S100, when determining the web page to be scaled, the server can determine whether the value of the preset flag in the uniform resource locator is a preset value. If so, the web page visited by the user is determined as the web page to be scaled. If not, the web page visited by the user is determined as the web page not to be scaled.
[0088] Since the browser will attach a user agent string when sending a Hyper Text Transfer Protocol (HTTP) request, which contains information about the browser and operating system, the server can determine the device type, operating system, browser version, etc. that displays the web page by parsing the user agent string in the HTTP request header, and determine whether the web page is a zoomable web page based on the device type that displays the web page.
[0089] That is, in response to the web page access operation of the user, the server receives the HTTP request sent by the browser where the web page is located, determines the user agent string in the HTTP request, and determines whether the web page is a web page for zooming according to the user agent string. Specifically, it is determined whether the user agent string includes a preset device type. If so, the web page accessed by the user is determined as a web page for zooming. If not, the web page accessed by the user is determined as a web page for not zooming. The preset device types include Mobile (mobile phone), Tablet (tablet), etc., which can be set as needed.
[0090] It should be noted that the identifier of the preset device type may be related to the version of the web page designed by the developer. For example, when the developer is designing, the version that the web page can adapt to is the computer. Then, the preset device type may include other display devices other than the computer, such as mobile phones, tablets, etc. This is because when the web page is initially designed, it has been set to adapt to the computer. Then, when the web page is displayed on the computer, there is no problem of incompatibility between Zoom and the size conversion function, and there is no need to determine whether the web page needs to be scaled.
[0091] A locator set may also be pre-set, and the set includes the uniform resource locators of all web pages that need to be scaled. Then, after obtaining the uniform resource locator of the web page clicked by the user, it is determined whether the uniform resource locator is in the preset locator set. If so, the web page visited by the user is determined as a web page to be scaled. If not, the web page visited by the user is determined as a web page not to be scaled. The scaling of the web page in the current step means that the web page needs to be scaled, rather than directly scaling the web page. In other words, if it is determined that the network element needs to be scaled, steps S102 to S106 need to be executed to complete the scaling of the web page.
[0092] The window size of the browser where the webpage is located can also be obtained, and the webpage is determined to be a webpage to be scaled according to the window size. Specifically, when the window size is not a preset window size, the webpage visited by the user is determined to be a webpage to be scaled. The preset window size can be set as needed, and this manual does not limit this.
[0093] Regarding step S102, when executing step S102, the initial predicted size determined is not the size in actual application. Step S102 is still preparing the parameters required by the rewriting function, rather than scaling through the unrewritten size conversion function. For example, the webpage scaling ratio is 0.5, the initial element size is 100*100, and the unrewritten size conversion function is y1=ax, a is the webpage scaling ratio, and x is the side length of the element. Then, the initial predicted size is y1, rather than 50 obtained by substituting a=0.5 and x=100 into y1.
[0094] For step S104, the server may not use a proxy when rewriting, but may create a wrapper function, in which the browser's own getBoundingClientRect function is called, and the getBoundingClientRect function is rewritten according to the initial predicted size and the target size. This method may add additional logic to the wrapper function without directly modifying the original getBoundingClientRect function.
[0095] In addition, the server may first execute steps S102 to S104 and then execute step S100. That is, the size conversion function is rewritten in advance, and then it is determined whether the webpage needs to be scaled. If necessary, step S106 is executed. By rewriting the function in advance, the scaling efficiency can be further improved, and the user experience can be improved.
[0096] After executing step S106, in order to scale the web page in time and improve the user experience, the server needs to determine the width transformation of the window in real time so that the web page content can be displayed to the user in the best display manner.
[0097] Specifically, the server determines whether the window width of the browser where the webpage is located has changed. If so, the server re-determines the webpage zoom ratio, and scales the webpage according to the re-determined webpage zoom ratio and the rewritten size conversion function. Since the size conversion function is rewritten by changing parameters in this specification, the rewritten size conversion function knows the relationship between the target size and the initial predicted size. Therefore, after adjusting the webpage zoom ratio, it is not necessary to rewrite the size conversion function for scaling again, thereby improving the efficiency of webpage scaling.
[0098] When determining whether the window width has changed, the server can determine whether the window width has changed by monitoring the resize event of the browser in real time. That is, by monitoring the size adjustment event, the window width of the browser where the web page is located is obtained in real time, and based on the browser window width obtained in real time, it is determined whether the window width of the browser where the web page is located has changed.
[0099] In addition, the Zoom method is not compatible with the getBoundingClientRect function, which is usually reflected in the display effects of components in external component libraries such as element-ui. For example, the el-dropdown and el-tooltip components are misaligned when not scrolling and when scrolling. When elements in a page are scaled using the Zoom method, their visual effects change, but their actual positions and sizes may not be updated accordingly. Therefore, when the server calculates the position of components such as el-dropdown and el-tooltip, it may use the actual position instead of the visual position, causing the components to be misaligned. The actual position refers to the real position in the document flow of the page, and the visual position refers to the position of the element relative to the viewport obtained by the getBoundingClientRect function. Similarly, when the page is scrolled, the server will recalculate the position of the element, but these calculations usually do not take into account the impact of scaling. Therefore, if the page is scaled using the Zoom method and there is a misalignment problem when scrolling, it may be because the impact of scaling was not taken into account when the element position was recalculated, resulting in misalignment.
[0100] In order to avoid display problems of components in external component libraries, when the server uses Proxy to rewrite the getBoundingClientRect function, it is also necessary to correct the display problems of components in the component library. For example, the server creates a proxy object getBoundingClientRectProxy through Proxy, and intercepts the call of the original getBoundingClientRect function in the apply method. In the interception function, it is determined whether the current element contains the component class name of the preset component library, where the component class name of the preset component library includes at least one of el-dropdown and el-tooltip. If so, the logic of misalignment correction is executed, including recalculating the position. Specifically, the server can obtain the width and height of the el-dropdown or el-tooltip component, and perform position correction based on the width and height. This ensures that the corrected position not only takes into account the position of the element, but also the size of the component itself, so as to achieve a more accurate misalignment correction effect.
[0101] It should be noted that this application does not limit the type of external component library, and the type of external component library is related to the display problem of the component in the component library being corrected. For example, if the display problem of the component in component library A is being corrected, then when judging whether the current element includes the component class name in component library A, if the display problem of the component in component library B is being corrected, then when judging whether the current element includes the component class name in component library B.
[0102] In order to improve the efficiency of web page design for developers, the web page scaling method provided in this manual can also be integrated into an NPM (Node Package Manager packages, NPM) package, which can be directly called to implement function rewriting for web page scaling.
[0103] The above is one or more implementation methods of this specification, based on Figure 1 The webpage zooming method shown in the flowchart is provided in the specification. The present specification also provides a corresponding webpage zooming device, such as Figure 3 shown.
[0104] Figure 3 A schematic diagram of a webpage zooming device provided in this specification includes:
[0105] A web page determination module 300, used to determine a web page to be scaled, and a size transformation function for transforming elements in the web page;
[0106] A size determination module 302, used to determine a size that can be obtained by transforming the element in the web page through the size transformation function as an initial predicted size;
[0107] A rewriting module 304, configured to rewrite the size transformation function according to the initial predicted size and the target size, so that the size obtained by transforming the element in the webpage according to the rewritten size transformation function is the target size;
[0108] The scaling module 306 is used to determine the webpage scaling ratio of the webpage; and scale the webpage according to the webpage scaling ratio and the rewritten size transformation function.
[0109] Optionally, the web page determination module 300 is specifically used to, in response to a user's web page access operation, obtain a uniform resource locator of a web page; determine whether the web page is a web page to be scaled based on the uniform resource locator; if so, determine the web page accessed by the user as a web page to be scaled; if not, determine the web page accessed by the user as a web page not to be scaled, and call a size conversion function provided by the browser where the web page is located through a Proxy agent.
[0110] Optionally, the web page determination module 300 is specifically used to determine whether the value of the preset flag in the uniform resource locator is a preset value; if so, determine the web page visited by the user as a zoomed web page; if not, determine the web page visited by the user as a non-zoomed web page.
[0111] Optionally, the size transformation function includes a getBoundingClientRec function; the rewriting module 304 is specifically used to rewrite the getBoundingClientRect function through a Proxy agent according to the initial predicted size and the target size, and the initial predicted size is negatively correlated with the target size.
[0112] Optionally, the zoom module 306 is specifically used to obtain the window width of the browser where the web page is located; when the window width of the browser is less than a first preset size, determine the web page zoom ratio as a first zoom ratio; when the window width of the browser is greater than a second preset size, determine the web page zoom ratio as a second zoom ratio; when the window width of the browser is not less than the first preset size and not greater than the second preset size, determine the web page zoom ratio according to a preset proportional relationship and the window width of the browser, the preset proportional relationship including a positive correlation between the web page zoom ratio and the window width of the browser.
[0113] Optionally, the scaling module 306 is specifically used to determine the initial size of each element in the web page; for each element in the web page, determine the first predicted size of the element according to the initial size of the element and the web page scaling ratio through the size transformation function; determine the second predicted size of the element according to the first predicted size and the web page scaling ratio through the rewritten size transformation function; and scale the web page through the Zoom method according to the second predicted sizes of each element in the web page.
[0114] Optionally, the device further comprises:
[0115] The monitoring module 308 is used to determine whether the window width of the browser where the webpage is located has changed; if so, redetermine the webpage zoom ratio; and scale the webpage according to the redetermined webpage zoom ratio and the rewritten size conversion function.
[0116] Optionally, the monitoring module 308 is specifically used to obtain the window width of the browser where the web page is located in real time by monitoring the size adjustment event; and determine whether the window width of the browser where the web page is located has changed according to the browser window width obtained in real time.
[0117] The present specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the webpage zooming method described above is implemented.
[0118] This specification also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 A web page zoom method is provided.
[0119] This manual also provides Figure 4 The one shown corresponds to Figure 1 Schematic diagram of the structure of an electronic device. Figure 4 As shown, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 The web page zoom method.
[0120] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the executor of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0121] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0122] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0123] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0124] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0125] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0126] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, 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 flowchart and / or block diagram. 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.
[0127] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate 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 A function specified in one or more boxes.
[0128] 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 instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0129] In a typical configuration, a computing device includes one or more processors (first chips), input / output interfaces, network interfaces, and memory.
[0130] The memory may include non-permanent storage 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.
[0131] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. 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 disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape 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 temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0132] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0133] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0134] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0135] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0136] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.
Claims
1. A webpage zooming method, characterized in that: The method comprises: Determine the web page to be scaled, and the size transformation function used to transform the elements in the web page; Determine a size that can be obtained by transforming the element in the webpage through the size transformation function as an initial predicted size; Rewriting the size transformation function according to the initial predicted size and the target size, so that the size obtained by transforming the element in the webpage according to the rewritten size transformation function is the target size; Determine the webpage zoom ratio of the webpage; and zoom the webpage according to the webpage zoom ratio and the rewritten size transformation function.
2. The method according to claim 1, characterized in that Determine the web pages to be scaled, including: In response to a web page access operation by a user, obtaining a uniform resource locator of the web page; According to the uniform resource locator, determining whether the webpage is a webpage to be scaled; If yes, determining the webpage visited by the user as the webpage to be zoomed; If not, the webpage visited by the user is determined as a webpage that is not to be scaled, and a size conversion function provided by the browser where the webpage is located is called through a Proxy agent.
3. The method according to claim 2, characterized in that Judging whether the webpage is a webpage to be scaled according to the uniform resource locator specifically includes: Determining whether the value of the preset flag bit in the uniform resource locator is a preset value; If yes, determining the webpage visited by the user as the webpage to be zoomed; If not, the webpage visited by the user is determined as a webpage that is not to be scaled.
4. The method according to claim 1, characterized in that The size conversion function includes a getBoundingClientRec function; According to the initial predicted size and the target size, the size conversion function is rewritten, specifically including: According to the initial predicted size and the target size, the getBoundingClientRect function is rewritten through a Proxy agent, and the initial predicted size is negatively correlated with the target size.
5. The method according to claim 1, characterized in that Determining a webpage zoom ratio of the webpage specifically includes: Obtaining the window width of the browser where the webpage is located; When the browser window width is smaller than a first preset size, determining the webpage zoom ratio as a first zoom ratio; When the browser window width is greater than a second preset size, the webpage zoom ratio is determined to be a second zoom ratio; When the window width of the browser is not less than the first preset size and not greater than the second preset size, the webpage zoom ratio is determined according to a preset proportional relationship and the window width of the browser, wherein the preset proportional relationship includes a positive correlation between the webpage zoom ratio and the window width of the browser.
6. The method according to claim 1, characterized in that Scaling the webpage according to the webpage scaling ratio and the rewritten size transformation function specifically includes: Determining the initial size of each element in the web page; For each element in the webpage, determining a first predicted size of the element according to the initial size of the element and the webpage zoom ratio by using the size transformation function; Determining a second predicted size of the element according to the first predicted size and the webpage zoom ratio by using the rewritten size transformation function; The webpage is scaled using a Zoom method according to the second predicted size of each element in the webpage.
7. The method according to claim 1, characterized in that The method further comprises: Determine whether the window width of the browser where the webpage is located has changed; If yes, re-determine the zoom ratio of the webpage; The web page is scaled according to the re-determined web page scaling ratio and the rewritten size conversion function.
8. The method according to claim 7, characterized in that Determining whether the window width of the browser where the webpage is located has changed specifically includes: By monitoring the size adjustment event, the window width of the browser where the web page is located is obtained in real time; According to the browser window width acquired in real time, it is determined whether the window width of the browser where the webpage is located has changed.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Webpage adaptation method and device, electronic equipment and medium
CN116204741A
Webpage display method and device, electronic equipment and computer readable storage medium
CN117055987A
Webpage exporting method and device, equipment and storage medium
CN117076811A
Webpage display mode and device, display equipment and storage medium
CN118260498A
System and method for using a dynamic webpage editor
US10614156B1
Cited By
Interface self-adaptive zooming method and system
CN119201328A
Code generation method and device, code display method and device and electronic equipment
CN120762652A
