Disclosure of Invention
The invention provides a webpage access method, a webpage access device, electronic equipment, a webpage access medium and a webpage access product, which are used for solving the technical problems of high development cost and poor user experience caused by the fact that the technical specification does not have adaptability in the prior art, and the purposes of reducing the development cost and improving the user experience are achieved.
In a first aspect, the present invention provides a method for accessing a web page, which is applied to a browser, and includes:
initiating a resource access request to a target client based on a Script tag preset in a webpage to be accessed; the Script tag comprises address information of the target client and request data to be transmitted;
passing the resource access request;
and receiving resource information returned by the target client based on the resource access request, and realizing resource loading of the webpage to be accessed according to the resource information.
Further, according to the web page access method provided by the present invention, the Script tag further includes a name of a callback function in a web page to be accessed, and the resource information includes a parameter of the callback function in the web page to be accessed;
correspondingly, the implementing resource loading of the web page to be accessed according to the resource information includes:
calling a callback function in the webpage to be accessed, and inputting the parameter in the resource information into the callback function to obtain a data processing result;
and realizing the resource loading of the webpage to be accessed according to the data processing result.
Further, according to the webpage access method provided by the invention, the resource information is a JavaScript script comprising parameters of a callback function in the webpage to be accessed;
correspondingly, the calling a callback function in the webpage to be accessed and inputting parameters in the resource information into the callback function to obtain a data processing result includes:
and running the JavaScript to call a callback function in the webpage to be accessed, and inputting parameters in the JavaScript to the callback function to obtain a data processing result.
Further, according to the web page access method provided by the invention, the parameter of the callback function in the web page to be accessed is a coded parameter.
Further, according to the web page access method provided by the present invention, the address information of the target client is address information based on an HTTPS protocol.
Further, according to the web page access method provided by the present invention, before initiating a resource access request to a target client based on a Script tag preset in a web page to be accessed, the method further includes:
determining a target client and generating address information of the target client;
determining request data to be transmitted, and encoding the request data to be transmitted;
generating a Script tag according to a format definition of the Script tag, address information of the target client and the encoded request data to be transmitted;
and setting the Script tag in the webpage to be accessed.
In a second aspect, the present invention further provides a web page accessing apparatus, which is applied in a browser, and includes:
the system comprises an initiating module, a resource accessing module and a resource accessing module, wherein the initiating module is used for initiating a resource accessing request to a target client based on a Script tag preset in a webpage to be accessed; the Script tag comprises address information of the target client and request data to be transmitted;
the releasing module is used for releasing the resource access request;
and the loading module is used for receiving the resource information returned by the target client based on the resource access request and realizing the resource loading of the webpage to be accessed according to the resource information.
In a third aspect, the present invention also provides an electronic device, including:
a processor, a memory, and a bus, wherein,
the processor and the memory are communicated with each other through the bus;
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the steps of the web page access method as described in any one of the above.
In a fourth aspect, the present invention also provides a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the steps of the web page access method as described above.
In a fifth aspect, the present invention also provides a computer program product comprising a computer program which, when executed by a processor, performs the steps of the web page access method as described in any one of the above.
The invention provides a webpage access method, a webpage access device, electronic equipment, a webpage access medium and a webpage access product, which are applied to a browser, wherein the method comprises the following steps: initiating a resource access request to a target client based on a Script tag preset in a webpage to be accessed; the Script tag comprises address information of the target client and request data to be transmitted; passing the resource access request; and receiving resource information returned by the target client based on the resource access request, and realizing resource loading of the webpage to be accessed according to the resource information. The webpage access method provided by the invention can be suitable for different browsers, reduces the development cost of suppliers, and improves the user experience.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the prior art, a conventional web page development technology AJAX (Asynchronous JavaScript and XML) has certain limitations in applications of different types of browsers, and in order to deal with the limitations brought by the web page development technology AJAX, a web page developer needs to perform a lot of extra work to ensure the availability of services. As in the application scenario of the IE browser shown in fig. 1, when the address of the web page request is found not to be the same source address as the current web page, the IE browser directly rejects the request, and interaction between the web page and the client cannot be achieved. In the Chrome browser scenario shown in fig. 2, when a cross-domain request is to be implemented, it is necessary to set a configuration that a client can support the cross-domain request, otherwise, the cross-domain request sent by a web page cannot be received. In this case, a feasible solution is to upgrade the existing client program to enable the client to support cross-domain access, but still cannot solve the problem in the IE browser scenario shown in fig. 1, so the web page developer may have to tell the user "please access the website for your access experience by using Chrome browser" when the user accesses using the IE browser, which easily results in poor user experience.
Moreover, in the prior art, different technical specifications need to be adapted to different browsers, so that the development cost of a provider is high.
Fig. 3 is a schematic flowchart of a web page access method provided by the present invention, and as shown in fig. 3, the web page access method provided by the present invention is applied to a browser, and includes the following steps:
step 301: initiating a resource access request to a target client based on a Script tag preset in a webpage to be accessed; the Script tag comprises address information of the target client and request data to be transmitted.
In this embodiment, a request for resource access needs to be initiated to a target client through a Script tag preset in a to-be-accessed webpage. The Script tag is used for defining a client Script, such as JavaScript, and the Script tag may contain a Script statement and may also point to an external Script file through an src attribute. As in this embodiment, the request address provided by the target client is filled in the src attribute of the Script tag, and the Script tag includes not only address information of the target client but also request data to be transmitted. The definition format of the Script tag is as follows:
<script type=“text/javascript”
src=“https://127.0.0.1:8888/index?
callback=callback&body=encrypteddata”>
</script>
wherein, in the above defined format, src ═ https://127.0.0.1: 8888/index? Request address information indicating a target client, and callback and body indicating request data to be transmitted.
It should be noted that the target client refers to other application programs corresponding to different web pages in the terminal, such as a network disk software, a communication software, and the like. And the terminal can be electronic equipment of common application, such as a mobile phone, a computer and the like. The target client is not specifically limited herein.
It should be noted that JavaScript (usually abbreviated as JS) is a high-level, interpreted programming language, a language based on prototypes and header functions, a multi-modal language, and supports object-oriented programming, instruction-based programming, and functional programming, and provides different syntax to manipulate texts, arrays, dates, and regular expressions, and although not supporting I/O, it can be supported by its host environment. Currently, the standardization of the language implemented by ECMA (european computer manufacturers association) through ECMAScript is used by most web sites in the world and is also supported by world mainstream browsers (Chrome, IE, Firefox, Safari, Opera).
Step 302: and releasing the resource access request.
In this embodiment, when the browser determines that the resource access request (HTTPS request) is a resource request initiated by a Script tag, the browser may pass the resource request even if the address information in the resource request is different from the website information of the web page to be accessed. It should be noted that the method provided by this embodiment is applicable to any type of browser, such as an IE browser, a Chrome browser, and the like.
For example, if the website address information of the web page to be accessed is https:// www.b.com/index, the target browser finds a resource access request, determines that the resource access request is initiated by a Script tag, and the address information of the request target client included in the resource access request is https:127.0.0.1: aaaa/index, which is different from the website address information of the web page to be accessed, but since the resource access request is initiated by the Script tag, the browser will release the resource access request.
For another example, a user uses a certain browser to access a to-be-accessed webpage (e.g., https:// www, baidu.com), a part of functions in the to-be-accessed webpage need to request a target client to provide an address (e.g., https://127.0.0.1:8888/client/api, whether a hundredth-degree-network-disk client is installed in a PC is obtained by initiating a resource access request), and the resource access request initiated by a Script tag in the to-be-accessed webpage needs to be subjected to security judgment of the browser to confirm whether the request is allowed to be initiated. If the resource request is allowed to be released by the browser, the webpage to be accessed can acquire that the hundred-degree network disk client is installed in the PC.
Step 303: and receiving resource information returned by the target client based on the resource access request, and realizing resource loading of the webpage to be accessed according to the resource information.
In the embodiment, after receiving the resource information returned by the target client based on the resource access request, the resource loading of the webpage to be accessed is realized according to the resource information.
In this embodiment, a callback function with a function name of callback function is predefined, and the callback function is directly called when receiving resource information returned by the target client, and is used for processing corresponding data returned by the target client. And the processing result of the callback function on the data returned by the target client is loaded into the webpage to be accessed, so that the resource loading of the webpage to be accessed is realized.
It should be noted that the callback function refers to a function defined according to the JavaScript language specification, which can be called to be executed, and is used for processing data returned by the target client.
The webpage access method provided by the embodiment of the invention is applied to a browser, and a resource access request is sent to a target client based on a Script tag preset in a webpage to be accessed, wherein the Script tag comprises address information of the target client and request data to be transmitted, and the resource access request is released; and receiving resource information returned by the target client based on the resource access request, and realizing resource loading of the webpage to be accessed according to the resource information. The webpage access method provided by the invention can be suitable for different types of browsers, reduces the development cost of suppliers, and improves the user experience.
In another embodiment of the present invention, the Script tag further includes a name of a callback function in the web page to be accessed, and the resource information includes a parameter of the callback function in the web page to be accessed;
correspondingly, the implementing resource loading of the web page to be accessed according to the resource information includes:
calling a callback function in the webpage to be accessed, and inputting the parameter in the resource information into the callback function to obtain a data processing result;
and realizing the resource loading of the webpage to be accessed according to the data processing result.
In this embodiment, a callback function in the to-be-accessed webpage needs to be called according to the received resource information, and a parameter in the resource information returned from the target client is input into the callback function to obtain a data processing result, and then the resource loading of the to-be-accessed webpage is realized according to the data processing result to obtain the loading of the resource data related to the to-be-accessed webpage. If picture data, character data and the like need to be loaded.
It should be noted that the Script tag further includes a name of a callback function in the to-be-accessed webpage, the resource information includes a parameter of the callback function in the to-be-accessed webpage, and the data processing result is obtained by inputting the parameter of the callback function included in the resource information into the callback function corresponding to the name of the parameter. The format of the callback function is as follows:
function callback { processing data returned by client }.
It should be noted that, the callback function to be accessed by the called callback function may be predefined, for example, the callback function with the above format is predefined, and the predefined callback function may ensure that the data returned by the target client can be correctly received, and perform processing on the service logic of the web page to be accessed. The specific definition is the one in the prior art, and is not limited herein.
According to the webpage access method provided by the embodiment of the invention, the parameters in the resource information returned by the target client are input into the callback function in the webpage to be accessed to obtain the data processing result, and the resource loading processing of the webpage to be accessed is realized according to the data processing result. The method and the device can improve the accuracy of resource loading of the accessed webpage and improve the efficiency of data processing.
In another embodiment of the present invention, the resource information is a JavaScript script including a parameter of a callback function in the to-be-accessed webpage;
correspondingly, the calling a callback function in the webpage to be accessed and inputting parameters in the resource information into the callback function to obtain a data processing result includes:
and running the JavaScript to call a callback function in the webpage to be accessed, and inputting parameters in the JavaScript to the callback function to obtain a data processing result.
In this embodiment, the resource information returned by the target client is a JavaScript script including a parameter of a callback function in a webpage to be accessed, and when finding that the received resource information returned by the target client is the JavaScript script, the browser directly runs the JavaScript script, so as to call the callback function in the webpage to be accessed, and input the corresponding parameter into the callback function, thereby obtaining a data processing result.
It should be noted that, after receiving a resource access request initiated by a browser, a target client processes the resource access request, and after the processing is completed, obtains data in a JavaScript format as resource information and returns the resource information to the browser, where the resource information is a JavaScript script including a parameter of a callback function in a web page to be accessed.
According to the webpage access method provided by the embodiment of the invention, when the resource information comprises the JavaScript of the parameters of the callback function in the webpage to be accessed, the JavaScript is operated to call the callback function in the webpage to be accessed, and the parameters in the JavaScript are input into the callback function to obtain the data processing result, so that the data processing speed can be ensured, and the data processing accuracy can be ensured.
In another embodiment of the present invention, the parameter of the callback function in the webpage to be accessed is an encoded parameter.
In this embodiment, the parameters of the callback function in the web page to be accessed are parameters after encoding processing, and in this embodiment, all request data to be transmitted are encoded, it should be noted that all the request data are encoded, so as to make the requested data easy to manage and expand, and a specific encoding manner may be a mature encoding manner in the prior art, which is not particularly limited.
According to the webpage access method provided by the invention, the parameters of the callback function in the webpage to be accessed are coded, so that the request data can be managed and expanded conveniently, and the user experience is improved.
In another embodiment of the present invention, the address information of the target client is address information based on an HTTPS protocol.
In this embodiment, the address information of the target client is address information transmitted based on the HTTPS protocol. It should be noted that HTTPS HyperText Transfer Protocol Secure (HTTP over TLS), which is often called HTTP over SSL or HTTP Secure, is a transport Protocol for Secure communication over a computer network, and HTTPS encrypts a packet using SSL/TLS although communicating via HTTP. The main purpose of HTTPS development is to provide authentication to web servers and protect the privacy and integrity of the exchanged data.
In the security specification of the browser before 2010, it is stated that when address information of a web page is transmitted by using an HTTPS protocol, any resource using the HTTP protocol cannot be acquired, because the resource acquired by using the HTTP protocol may reduce the security of the web page using the HTTPS protocol.
According to the webpage access method provided by the invention, the address information of the target client is set by adopting an HTTPS protocol, so that the condition that the access security level of the current webpage is intercepted by a browser is avoided, the accuracy of the address information transmitted between the accessed webpage and the target client is ensured, the privacy and the integrity of exchanged data are protected, and the condition that the browser can correctly execute any webpage when any type of browser browses any webpage is ensured.
In another embodiment of the present invention, before initiating a resource access request to a target client based on a Script tag preset in a to-be-accessed webpage, the method further includes:
determining a target client and generating address information of the target client;
determining request data to be transmitted, and encoding the request data to be transmitted;
generating a Script tag according to a format definition of the Script tag, address information of the target client and the encoded request data to be transmitted;
and setting the Script tag in the webpage to be accessed.
In this embodiment, a target client needs to be determined, corresponding address information is generated according to the determined target client, request data to be transmitted needs to be determined, encoding processing is performed on the request data to be transmitted, then a Script tag is generated according to a format definition of the Script tag, the address information of the target client and the encoded request data to be transmitted, and the obtained Script tag is arranged in a webpage to be accessed for subsequent interaction with the target client.
It should be noted that, in this embodiment, a Script tag in HTML is adopted, and HyperText Markup Language (HTML for short) is a standard Markup Language for creating a web page. HTML is a basic technology that is often used by many websites, along with CSS and JavaScript, to design user interfaces for web pages, web applications, and mobile applications. HTML describes the structural semantics of a web site, and is a markup language rather than a programming language, and a web browser can read an HTML file and render it into a visual web page.
According to the webpage access method provided by the invention, before the resource access request is initiated to the target client, the Script tag is generated according to the format definition of the Script tag, the address information of the target client and the coded request data to be transmitted, and the generated Script tag is arranged in the webpage to be accessed for subsequently initiating the resource access request to the target client, so that the interaction performance between the webpage and the client is improved, and the user experience is improved.
In another embodiment of the present invention, as shown in fig. 4, the request interaction between the to-be-accessed webpage and the target client uses a Script tag in HTML to load resources and perform communication by using the Script tag. Filling a request address provided by a target client in the src attribute of the Script tag, wherein the request address requests to transmit two parameters, namely the name of a callback function in a webpage to be accessed and all request data to be transmitted after encoding, by using an HTTPS protocol. And after receiving the resource access request, the target client returns the resource access request in a data format of JavaScript data after processing the resource access request, wherein the data needing to be returned in the JavaScript is coded and processed and then is transmitted as the parameter of the callback function.
The specific implementation is as follows: if the web address of the web page to be accessed, which is opened by the user on the browser, is: https:// www.a.com/index, and a Script tag is introduced in the web page to be accessed for requesting the interface provided by the target client. The method comprises the steps that a browser launches a resource access request when finding that the resource access request is initiated by a Script tag, the resource access request can be released even if address information of the resource access request and website information of a webpage to be accessed are not homologous addresses, a target client processes the received resource access request and returns processed data to the browser in a JavaScript format, the browser finds that the returned data is one JavaScript, the Script can be directly operated, a defined callback function is called, the returned data is input into the callback function as a parameter of the callback function to obtain the processed data, resource loading of the webpage to be accessed is carried out according to the processed data, and a user interface corresponding to the webpage to be accessed is obtained. The address information of the request target client included in the resource access request is https:127.0.0.1: aaaa/index, and the format of the callback function is function callback (data processing) { processing data returned by the client }.
In this embodiment, the provided web page access method may be applied to diversified user scenarios, for example, a user a uses a chrome browser to access a web page in a windows10 operating system, a user B uses an IE browser to access a web page in a windows xp operating system, and a user C uses a Safari browser to access a mac os operating system. The webpage access method provided by the invention can realize the consistency of safety specifications of different browsers in different operating systems on the request interaction of the webpage and the target client, realizes one-time development and multiple-place use, and greatly reduces the development adaptation cost of suppliers under different application scenes.
Fig. 5 is a web page access apparatus provided in an embodiment of the present invention, and as shown in fig. 5, the web page access apparatus provided in an embodiment of the present invention is applied to a browser, and includes:
an initiating module 501, configured to initiate a resource access request to a target client based on a Script tag preset in a to-be-accessed webpage; the Script tag comprises address information of the target client and request data to be transmitted;
a releasing module 502, configured to release the resource access request;
a loading module 503, configured to receive resource information returned by the target client based on the resource access request, and implement resource loading of the to-be-accessed webpage according to the resource information.
The webpage access device provided by the invention is applied to a browser, and initiates a resource access request to a target client based on a Script tag preset in a webpage to be accessed; the Script tag comprises address information of a target client and request data to be transmitted; releasing the resource access request; and receiving resource information returned by the target client based on the resource access request, and realizing resource loading of the webpage to be accessed according to the resource information. The webpage access device provided by the invention can be suitable for different types of browsers, reduces the development cost of suppliers, and improves the user experience.
Further, the Script tag further includes a name of a callback function in a webpage to be accessed, and the resource information includes a parameter of the callback function in the webpage to be accessed;
accordingly, the loading module 503 is further configured to:
calling a callback function in the webpage to be accessed, and inputting the parameter in the resource information into the callback function to obtain a data processing result;
and realizing the resource loading of the webpage to be accessed according to the data processing result.
According to the webpage access device provided by the embodiment of the invention, the parameters in the resource information returned by the target client are input into the callback function in the webpage to be accessed to obtain the data processing result, and the resource loading processing of the webpage to be accessed is realized according to the data processing result. The method and the device can improve the accuracy of resource loading of the accessed webpage and improve the efficiency of data processing.
Further, the resource information is a JavaScript script comprising parameters of a callback function in the webpage to be accessed;
accordingly, the loading module 503 is further configured to:
and running the JavaScript to call the callback function in the webpage to be accessed, and inputting the parameter of the callback function into the callback function to obtain a data processing result.
According to the webpage access device provided by the embodiment of the invention, when the resource information comprises the JavaScript of the parameters of the callback function in the webpage to be accessed, the JavaScript is operated to call the callback function in the webpage to be accessed, and the parameters in the JavaScript are input into the callback function to obtain the data processing result, so that the data processing speed can be ensured, and the data processing accuracy can be ensured.
Further, according to the web page access device provided by the present invention, the parameter of the callback function in the web page to be accessed is a coded parameter.
According to the webpage access device provided by the invention, the parameters of the callback function in the webpage to be accessed are coded, so that the request data can be managed and expanded conveniently, and the user experience is improved.
Further, according to the web page access apparatus provided by the present invention, the address information of the target client is address information based on an HTTPS protocol.
According to the webpage access device provided by the invention, the address information of the target client is set by adopting an HTTPS protocol, so that the accuracy of the address information transmitted between the accessed webpage and the target client can be ensured, the privacy and the integrity of the exchanged data are protected, and the browser can be ensured to be correctly executed when any webpage is browsed by any type of browser.
Further, before initiating a resource access request to a target client based on a Script tag preset in a to-be-accessed webpage, the apparatus further includes:
the first generation unit is used for determining a target client and generating address information of the target client;
the encoding unit is used for determining the request data to be transmitted and encoding the request data to be transmitted;
the second generating unit is used for generating the Script tag according to the format definition of the Script tag, the address information of the target client and the encoded request data to be transmitted;
and the setting unit is used for setting the Script tag in the webpage to be accessed.
According to the webpage access device provided by the invention, before a resource access request is initiated to a target client, the Script tag is generated according to the format definition of the Script tag, the address information of the target client and the coded request data to be transmitted, and the generated Script tag is arranged in the webpage to be accessed for subsequently initiating the resource access request to the target client, so that the interaction performance between the webpage and the client is improved, and the user experience is improved.
Since the principle of the apparatus according to the embodiment of the present invention is the same as that of the method according to the above embodiment, further details are not described herein for further explanation.
Fig. 6 is a schematic structural diagram of an electronic device provided in an embodiment of the present invention, and as shown in fig. 6, the present invention provides an electronic device, including: a processor (processor)601, a memory (memory)602, and a bus 603;
the processor 601 and the memory 602 complete communication with each other through the bus 603;
the processor 601 is used for calling the program instructions in the memory 602 to execute the methods provided in the above-mentioned embodiments of the methods, for example, including: initiating a resource access request to a target client based on a Script tag preset in a webpage to be accessed; the Script tag comprises address information of the target client and request data to be transmitted; and releasing the resource access request, receiving resource information returned by the target client based on the resource access request, and loading the resources of the webpage to be accessed according to the resource information.
Embodiments of the present invention provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to perform the methods provided in the above-described method embodiments, for example, including: initiating a resource access request to a target client based on a Script tag preset in a webpage to be accessed; the Script tag comprises address information of the target client and request data to be transmitted; and releasing the resource access request, receiving resource information returned by the target client based on the resource access request, and loading the resources of the webpage to be accessed according to the resource information.
The present invention also provides a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the method provided by the embodiments described above, the method comprising: initiating a resource access request to a target client based on a Script tag preset in a webpage to be accessed; the Script tag comprises address information of the target client and request data to be transmitted; and releasing the resource access request, receiving resource information returned by the target client based on the resource access request, and loading the resources of the webpage to be accessed according to the resource information.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.