Multi-page management method and device
Technical field
The present invention relates to internet area more particularly to a kind of multi-page management method and devices.
Background technique
Hypertext markup language (Hypertext Markup Language, HTML) is one for describing web document
Kind markup language.Current newest World Wide Web Consortium (World Wide Web, W3C) HTML5 standard is formally finalized a text, but should
Standard still in improve among.Webpage real time communication (Web Real-Time Communication, WebRTC) and network socket
Word (WebSocket) is two important new technologies in HTML5.WebRTC can provide client to the communication equipment of client
System, to realize the communication of audio-video and other data between two clients.The technology changes in previous HTML technology
The situation of the communication of client to server (Client-Server, CS) mode can only be carried out, so that carrying out in network (Web)
The real time communication of client to client is possibly realized.WebSocket technology can provide a kind of server end and client it
Between two-way, continuous communication mechanism.The appearance of WebSocket technology, so that client and server end is two-way, continuous
Communication is possibly realized.In the communication of actual client to client, data channel and two kinds of signalling path letters are generally required
Transmission channel is ceased, wherein data channel is used for transmission the application data mutually exchanged between user, and signalling path is then used to help
It helps between client and establishes and manage connection.In the audio/video communication system constructed based on WebRTC, usually with WebSocket
As the channel for transmitting signaling between server and client side.
Using WebSocket as WebRTC signalling path, there are some problems.First is that user's habit opens simultaneously multiple nets
Page, each webpage can establish a WebSocket between client and server, repeat connection to server and client side
It consumes huge;Second is that user's habit is jumped between each page by hyperlink, the JavaScript of current page when jumping
Context is destroyed, WebSocket disconnect, to target pages after re-establish WebSocket, WebSocket's frequently cuts off
Or reconnection operation consumes resource so that the presence of user frequently changes;Third is that when page jump, in the disconnected of WebSocket
Open or reconnection during, communication between server and client side will lose.
Worker thread (Web Worker) specification in HTML5 standard can provide the thread independently of the page, change
In the past in network (Web) script single thread limitation, provide certain cross-page face ability.But Web Worker is only applicable to
Thread and thread when opening simultaneously multiple pages are shared, and thread when not being suitable for common variables or page jump is shared, page
Web Worker still will disconnect or reconnection when face jumps.
Usually in common multithreading, the skills such as communication, synchronization, shared variable between multiple threads are also frequently involved
Art, these technologies have been directed to the technology of the interaction between multiple threads.But the cross-page face shared variable that encounters of web sphere and
Common multithreading problems faced is very different, and essentially consists in common multithreading, each function/line
Journey is nested structure, and each function/thread belongs to the respective page in web technology, since each page is mutually indepedent, across
There is no nest relations between the variable and thread of the page, and a critically important scene is page jump in Web technology, and general
Logical multithreading will not relate to similar situation.
In conclusion the signalling path between client and server is likely to occur in the browser for supporting multiple web pages
It repeats to connect, causes system resource waste.
Summary of the invention
Technical problem
In view of this, how the technical problem to be solved by the present invention is to save system resource.
Solution
An embodiment according to the present invention, in a first aspect, providing a kind of multi-page management method, comprising:
Client is requested according to the page jump received, searches whether that the scope of cross-page face variable includes page object
Face;
In the case where finding the scope of cross-page face variable includes target pages, for target pages addition pair
The reference of the cross-page face variable;
The corresponding page of the cross-page face variable is used to share content in the target pages.
With reference to first aspect, in the first possible implementation of the first aspect, which also wraps
It includes:
The client is requested according to the page open received, searches whether that the scope of cross-page face variable includes mesh
Mark the page.
With reference to first aspect or the first possible implementation of first aspect, second in first aspect are possible
In implementation, the multi-page management method further include:
The client deletes according to the page close request received and needs the page closed to the cross-page face variable
Reference;
Search whether the cross-page face variable is quoted by other pages;
In the case where the cross-page face variable is not quoted by other pages, the corresponding page of the cross-page face variable is destroyed
Shared content.
With reference to first aspect or its any one possible implementation, in the third possible realization side of first aspect
In formula, search whether that the scope of cross-page face variable includes target pages, comprising:
The client receives the target pages from server, includes cross-page face in the procedure script of the target pages
Variable declarations, the cross-page face variable declarations include the title and scope of the corresponding cross-page face variable of the target pages, institute
State equipment pointed by the uniform resource position mark URL that server is the target pages, the title packet of the cross-page face variable
Include variable name and/or shared name;
According to the title of the cross-page face variable, the page that searches whether to have been friends in the past has built up the name with the cross-page face variable
Claim identical cross-page face variable, and judges whether the scope of the cross-page face variable of the same name found includes the page object
Face.
With reference to first aspect or its any one possible implementation, in the 4th kind of possible realization side of first aspect
In formula, the reference to the cross-page face variable is added for the target pages, comprising:
Update the numerical value in reference counter, or save the cross-page face variable and the target pages identification information it
Between adduction relationship, the numerical value in the reference counter is for indicating the number that the cross-page face variable is currently cited;
The cross-page face is read from the memory of client according to the title of the corresponding cross-page face variable of the target pages
The corresponding page of variable shares content.
With reference to first aspect or its any one possible implementation, in the 5th kind of possible realization side of first aspect
In formula, the cross-page face variable needs common page info variable to be sharing for indicating, uses institute in the target pages
It states the corresponding page of cross-page face variable and shares content, comprising: the client reads the page info in the target pages
The corresponding page info of variable;Or
The cross-page face variable needs thread variable to be sharing for indicating, uses the cross-page face in the target pages
The corresponding page of variable shares thread, comprising: the client runs the corresponding line of the thread variable in the target pages
Journey;Or
The cross-page face variable is the signalling path variable for indicating to need to establish between client and server, in the mesh
Marking the page uses the corresponding page of the cross-page face variable to share content, comprising: the client is used in the target pages
Signalling path resource corresponding to the signalling path variable, from the server sending and receiving data.
With reference to first aspect, in the sixth possible implementation of the first aspect, it is added for the target pages
After the reference of the cross-page face variable, comprising:
It is requested according to page jump, deletes reference of the old page to the cross-page face variable;
Search whether the cross-page face variable is quoted by other pages;
In the case where the cross-page face variable is not quoted by other pages, the corresponding page of the cross-page face variable is destroyed
Shared content.
The 6th kind of possible implementation with reference to first aspect, in the 7th kind of possible implementation of first aspect
In, after adding for the target pages to the reference of the cross-page face variable, the old page is deleted to the cross-page face
Before the reference of variable, comprising:
Destroy the script running environment of the old page;
The page switching that the client is currently shown is the target pages;
Render the script running environment of the target pages.
Second and third or seven kinds of possible implementations with reference to first aspect, in the 8th kind of possible reality of first aspect
In existing mode, search whether the cross-page face variable is quoted by other pages, comprising:
According to the numerical value of the corresponding reference counter of the cross-page face variable, determine the cross-page face variable whether by other
Page reference;Or
According to the adduction relationship between the cross-page face variable and the identification information of the target pages, determine described cross-page
Whether face variable is quoted by other pages.
Second aspect provides a kind of multi-page managing device, comprising:
Searching module, for searching whether the scope packet of cross-page face variable according to the page jump request received
Include target pages;
Module is quoted, is communicated with the searching module, for including mesh finding the scope of cross-page face variable
In the case where marking the page, the reference to the cross-page face variable is added for the target pages;
Sharing module is communicated with the reference module, for using the cross-page face variable pair in the target pages
The page answered shares content.
In conjunction with second aspect, in the first possible implementation of the second aspect, the searching module is also used to root
According to the page open request received, search whether that the scope of cross-page face variable includes target pages.
In conjunction with the possible implementation of the first of second aspect or second aspect, second in second aspect is possible
In implementation, multi-page managing device further include:
Removing module, for deleting and needing the page closed to the cross-page face according to the page close request received
The reference of variable;In the case where the searching module finds the cross-page face variable and do not quoted by other pages, institute is destroyed
It states the corresponding page of cross-page face variable and shares content.
In conjunction with second aspect or its any one possible implementation, in the third possible realization side of second aspect
In formula, multi-page managing device further include:
Receiving module, for receiving the cross-page face variable declarations of the target pages, the cross-page face variable from server
Statement includes the title and scope of the corresponding cross-page face variable of the target pages, and the server is the target pages
The title of equipment pointed by uniform resource position mark URL, the cross-page face variable includes variable name and/or shared name;
The searching module is also used to the title according to the cross-page face variable, the page that searches whether to have been friends in the past have built up with
The identical cross-page face variable of the title of the cross-page face variable, and judge that the scope of cross-page face variable of the same name found is
No includes the target pages.
In conjunction with second aspect or its any one possible implementation, in the 4th kind of possible realization side of second aspect
In formula, multi-page managing device further include:
Read module reads the cross-page face for the variable name according to the target pages from the memory of client and becomes
It measures the corresponding page and shares content;
The reference module is also used to update the numerical value in reference counter, or saves the cross-page face variable and the mesh
The adduction relationship between the identification information of the page is marked, the numerical value in the reference counter is for indicating that the cross-page face variable is worked as
Before the number that is cited.
In conjunction with second of possible implementation of second aspect, in the 5th kind of possible implementation of second aspect
In, the removing module is also used to after adding for the target pages to the reference of the cross-page face variable, according to the page
Jump request deletes reference of the old page to the cross-page face variable;The cross-page face is found in the searching module
In the case that variable is not by the reference of other pages, destroys the corresponding page of the cross-page face variable and share content;Or
The removing module is also used to after adding for the target pages to the reference of the cross-page face variable, is deleted
Before the old page is to the reference of the cross-page face variable, the script running environment of the old page is destroyed;By the client
Holding the page switching currently shown is the target pages;Render the script running environment of the target pages.
Beneficial effect
The embodiment of the present invention can be added if there is the scope of cross-page face variable includes target pages in target pages
Reference to the cross-page face variable shares content using the corresponding page of cross-page face variable in target pages, can pass through variable
It realizes resource-sharing, reduces system resource waste.
According to below with reference to the accompanying drawings becoming to detailed description of illustrative embodiments, other feature of the invention and aspect
It is clear.
Detailed description of the invention
Comprising in the description and constitute the attached drawing of part of specification and specification together illustrate it is of the invention
Exemplary embodiment, feature and aspect, and principle for explaining the present invention.
Fig. 1 is the flow chart of the multi-page management method of the embodiment of the present invention one;
Fig. 2 is the flow chart that the page is opened in the multi-page management method of the embodiment of the present invention one;
Fig. 3 is the flow chart that the page is closed in the multi-page management method of the embodiment of the present invention one;
Fig. 4 is the thread management structure chart of the browser of the multi-page management method of the embodiment of the present invention two;
Fig. 5 is the flow chart that browser opens the page in the multi-page management method of the embodiment of the present invention two;
Fig. 6 is the flow chart that browser closes the page in the multi-page management method of the embodiment of the present invention two;
Fig. 7 is the flow chart that browser page jumps in the multi-page management method of the embodiment of the present invention two;
Fig. 8 is the structural block diagram of the multi-page managing device of the embodiment of the present invention three;
Fig. 9 is the structural block diagram of the multi-page managing device of the embodiment of the present invention four;
Figure 10 is the structural block diagram of the multi-page managing device of the embodiment of the present invention five.
Specific embodiment
Below with reference to attached drawing various exemplary embodiments, feature and the aspect that the present invention will be described in detail.It is identical in attached drawing
Appended drawing reference indicate element functionally identical or similar.Although the various aspects of embodiment are shown in the attached drawings, remove
It non-specifically points out, it is not necessary to attached drawing drawn to scale.
Dedicated word " exemplary " means " being used as example, embodiment or illustrative " herein.Here as " exemplary "
Illustrated any embodiment should not necessarily be construed as preferred or advantageous over other embodiments.
In addition, in order to better illustrate the present invention, numerous details is given in specific embodiment below.
It will be appreciated by those skilled in the art that without certain details, the present invention equally be can be implemented.In other example,
Method well known to those skilled in the art, means, element and circuit are not described in detail, in order to highlight master of the invention
Purport.
Embodiment 1
Fig. 1 is the flow chart of the multi-page management method of the embodiment of the present invention one.As shown in Figure 1, multi-page manager
Method specifically includes that
Step 110, client are requested according to the page jump received, search whether the scope packet of cross-page face variable
Include target pages.
Specifically, client can be various forms of browsers in the embodiment of the present invention.If browser is currently
The a certain page is opened, user's selection opens target pages in a browser or clicks a certain hyperlink for opening target pages
When, browser can receive page jump request.It may include the target pages for needing to jump in page jump request
Page info, such as: the identification information of target pages or hyperlink etc..Wherein, hyperlink, which can be in html page, includes
Uniform resource locator (Uniform Resource Locator, URL) pointer, after user's clickable hyperlinks, browser can
To be jumped from current page to target pages pointed by URL.
Wherein, if client has the page having already turned on, the cross-page face variable that the page having already turned on is created
Setting regions can be stored in.Client receive page jump request after, can have been searched whether in setting regions across
The scope of page variable includes target pages, and detailed process may include:
The client receives the target pages from server, includes cross-page face in the procedure script of the target pages
Variable declarations, the cross-page face variable declarations include the title and scope of the corresponding cross-page face variable of the target pages, institute
State equipment pointed by the uniform resource position mark URL that server is the target pages, the title packet of the cross-page face variable
Include variable name and/or shared name;
According to the title of the cross-page face variable, the page that searches whether to have been friends in the past has built up the name with the cross-page face variable
Claim identical cross-page face variable, and judges whether the scope of the cross-page face variable of the same name found includes the page object
Face.
Wherein, the cross-page face variable in the embodiment of the present invention refers to that needs realize shared variable between multiple pages,
Such as: WebSocket, Variable, the Thread etc. for needing cross-page face shared.
Step 120, in the case where finding the scope of cross-page face variable includes target pages, be the page object
Add the reference to the cross-page face variable in face.
It specifically, may include: more to the detailed process of the reference of the cross-page face variable for target pages addition
Numerical value in new reference counter, or the reference saved between the cross-page face variable and the identification information of the target pages are closed
It is that the numerical value in the reference counter is for indicating the number that the cross-page face variable is currently cited;According to the target
It is shared interior that the title of the corresponding cross-page face variable of the page reads the corresponding page of the cross-page face variable from the memory of client
Hold.
Wherein, the shared content of the different corresponding pages of cross-page face variable can be different.For example, for WebSocket, it is right
The page answered, which shares content, can be client to the channel WebSocket between server;It is corresponding for thread (Thread)
The page share content can be the shared thread run in client;For other common Variable, the corresponding page
Shared content can be the shared information for including in the old page of client such as: commodity data, user information.
Furthermore, it is possible to record each page in client for the specific reference situation of cross-page face variable.For example, can be with
A reference counter is established for each cross-page face variable, in the reference counter of a newly-built cross-page face variable, reference
The initial value of counter can be " 1 ".Every reference for increasing a page to the cross-page face variable, the numerical value of the reference counter
Add " 1 ".Every reference for reducing by a page to the cross-page face variable, the numerical value of the reference counter subtract " 1 ".In the reference count
When the numerical value of device is " 0 ", it can indicate that no page quotes the cross-page face variable.For another example, cross-page face variable and page can be saved
Adduction relationship between the identification information in face.Every reference for increasing a target pages to the cross-page face variable, can save this
Adduction relationship between cross-page face variable and the identification information of the target pages.One Geju City page of every reduction is to the cross-page face variable
Reference, the adduction relationship between the cross-page face variable and the identification information of the old page can be deleted.It is any not recording
When adduction relationship, it can indicate that no page quotes the cross-page face variable.
Step 130 uses the corresponding page of the cross-page face variable to share content in the target pages.
Specifically, target pages can be different using the concrete mode that the corresponding page of cross-page face variable shares content.Tool
Body can be divided into following scene:
Scene one, the cross-page face variable can be used to indicate that the signalling path for needing to establish between client and server
Variable, step 130, which may include: the client, uses signaling corresponding to the signalling path variable in the target pages
Channel resource, from the server sending and receiving data;For example, other pages have can be used in target pages for WebSocket
The client of foundation is to the channel WebSocket between server, from server sending and receiving data.
Scene two, the cross-page face variable, which can be also used for expression, needs thread variable to be sharing, and step 130 can wrap
Include: the client runs the corresponding thread of the thread variable in the target pages.For example, for Thread, page object
Face can run the corresponding thread of the Thread in the client.
Scene three, the cross-page face variable, which can be used to indicate that, needs page info variable to be sharing, and step 130 can wrap
Include: the client reads the corresponding page info of the page info variable in the target pages.For example, for
Variable, target pages can read page info pointed by Variable from the memory of client.
Further, it after client receives page jump request, is closing the old page and is opening between new page
In a period of time, useful data can be first cached, loss of data is prevented, specifically, can also include: prior to step 110
Caching uses the corresponding page of the cross-page face variable to share the obtained data of content.And it is possible to load institute from server
State the page resource of target pages.Step 110 is executed again after the completion of the load of the page resource of target pages.
For example, if cross-page face variable is that websocket or other similar capable of generating in real time need to be handled by target pages
Data thread (Thread), then need the data that the cross-page face variable is generated in real time to be cached.And browser can be with
Pass through page resource that can be required from server load by HTTP request channel.
Further, due to the time interval between old page close and target pages are opened with one section, in order to anti-
Only in this time interval, cross-page face variable is destroyed, and can execute step 120 again is that the target pages are added to described
The old page is completed and then is closed in the reference of cross-page face variable.Specifically, after step 101 or step 120, judge whether
The detailed process for closing the old page may include: the reference for deleting the old page to the cross-page face variable;Search it is described across
Whether page variable is quoted by other pages;In the case where the cross-page face variable is not quoted by other pages, described in destruction
The corresponding page of cross-page face variable shares content.In this way, if new target pages refer to already existing cross-page face variable,
Then the reference counter of the cross-page face variable all will not be for " 0 " during entirely jumping, therefore the page variable will not be by
It destroys.Therefore, only a window is opened in a browser even for user and carry out the scene of page jump, cross-page face variable
It can still be shared.
Wherein, it searches whether the cross-page face variable is quoted by other pages, can specifically use any one following side
Formula:
Mode one, according to the numerical value of the corresponding reference counter of the cross-page face variable, determine that the cross-page face variable is
It is no to be quoted by other pages;For example, the numerical value of the reference counter of the cross-page face variable is " 0 ", cross-page face variable may indicate that
It is not quoted by other pages, for the numerical value more than or equal to " 1 ", may indicate that cross-page face variable is quoted by other pages.
Mode two, according to the adduction relationship between the cross-page face variable and the identification information of the target pages, determine
Whether the cross-page face variable is quoted by other pages.
Further, after step 101 or step 120, reference of the old page to the cross-page face variable is deleted
It before, can also include: the new target pages of load;Add reference of the target pages to the cross-page face variable;Described in destruction
The script running environment of the old page;The page switching that browser is currently shown is the target pages;Render the page object
The script running environment in face.
In one possible implementation, client, which is in, needs the case where opening the page, in this case, the multipage
Face management method can also include the process for opening the page, as shown in Fig. 2, can specifically include:
Step 210, client are requested according to the page open received, search whether the scope packet of cross-page face variable
Include target pages;
Specifically, when user needs to open a page in client such as a certain browser, browser be can receive
It is requested to page open.It may include the page info for the target pages that needs are opened in page open request, such as: page object
The identification information in face or hyperlink etc..Wherein, the scope for searching whether cross-page face variable includes the specific mistake of target pages
Journey may refer to the associated description of above-mentioned steps 110.
Step 220, in the case where finding the scope of cross-page face variable includes target pages, be the page object
Add the reference to the cross-page face variable in face;Detailed process may refer to the associated description of above-mentioned steps 120.
Step 230 uses the corresponding page of the cross-page face variable to share content in the target pages.Wherein, specifically
Process may refer to the associated description of above-mentioned steps 130.
In one possible implementation, client, which is in, needs the case where closing the page, in this case, the multipage
Face management method can also include the process for closing the page, as shown in figure 3, can specifically include:
Step 310, client delete according to the page close request received and need the page closed to the cross-page face
The reference of variable.
Step 320 searches whether the cross-page face variable is quoted by other pages.It specifically may refer to one He of aforesaid way
The associated description of mode two.
Step 330, in the case where the cross-page face variable is not quoted by other pages, destroy the cross-page face variable pair
The page answered shares content.
The multi-page management method of the present embodiment, if there is the scope of cross-page face variable includes target pages, Ke Yi
Target pages add the reference to the cross-page face variable, share content using the corresponding page of cross-page face variable in target pages,
Resource-sharing can be realized by variable, reduce system resource waste.
Embodiment 2
Fig. 4 is the thread management structure chart of the browser of the multi-page management method of the embodiment of the present invention two.With cross-page face
For variable is WebSocket, client is browser, under the premise of guaranteeing safety, the work of WebSocket can be expanded
With domain range, so that without disconnecting and reconnection when WebSocket is connected to the page jump between same site.It can specifically modify
Realization in JavaScript in WebSocket interface and browser to WebSocket.As shown in figure 4, the line of browser
Thread management structure may include: when front opening page area 41, cross-page face variable management region 43, target pages jump directorial area
Domain 45.
Wherein, when front opening page area 41 may include two parts, first is that in JavaScriptContext, that is, page
The performing environment of variable, this part can be realized using traditional JavaScript variable declarations and administrative skill;Second is that cross-page
The constructed fuction statement (referred to as cross-page face variable declarations) of face WebSocket, in the webpage of the website comprising multi-page, in sound
Which when bright WebSocket, allow to specify the jump target page that can share the WebSocket in homepage.
When being jumped from the homepage of browser towards target pages, if some of target pages in homepage
WebSocket's allows in shared target pages list, and cross-page face variable management region 43 can keep homepage
The channel WebSocket is completed until the JavaScript Context of target pages, and establishes the reference to the WebSocket.
Wherein, adduction relationship can be realized with reference counter.
What target pages jumped that management region 45 can recorde homepage and target pages jumps relationship, in succeeding target page
It is same to keep sharing WebSocket when face reverse skip is to homepage.Also, target pages jump management region 45 also
Ajax, Javascript can be executed.
Wherein, for the part Javascript, the constructed fuction statement of WebSocket can in page code, be modified
(i.e. cross-page face variable declarations) increase a shared variable name and a scope such as target pages list
(TargetList), such as:
Var websocket=new WebSocket (' ws: //www.example.com ', [], name, ['/
page2′]).Wherein, " websocket " is variable name, and " name " is the shared name of variable, and ['/page2 '] is target pages column
Table.Wherein, " websocket " is name of the variable in this page, and " name " is use when other pages quote the variable
Name.
For another example, target pages list also can be stated as all pages of same web site:
Var websocket=new WebSocket (' ws: //www.example.com ', [], name, [*]);
For another example, shared name can not also be increased newly, but variable name " websocket " is used to be used as shared variable name, namely
With other pages in this page, the name used when quoting the variable is " websocket ", only increases the effect of the variable
Domain.
Browser receive page open request or page jump request after, load target pages and to target pages into
During row parsing, it can check whether legal across the TargetList in variable declarations in the page and carry out corresponding position
Reason: if the target pages (1) in TargetList do not meet " origin policy ", it can report an error and ignore the URL;(2) if
Target pages in TargetList are not sky, can save the list.
In addition, existing browser is to the administrative mechanism of dependent variable: the effective range of each variable is limited in certain
In JavaScript Context, the script running environment of highest level be a Webpage (or corresponding html document, or
DOM after corresponding parsing).When browser leaves a page, corresponding script running environment and variable therein will be by pins
It ruins.And the embodiment of the present invention can modify browser to the administrative mechanism of variable.Referring to fig. 4, in a browser, in addition in the page
Outside corresponding JavaScript Context, cross-page face variable management region 43 is also created.Pass through cross-page face variable management region
43 can control the cross-page face variable management in opening, closing and the redirect procedure of the page.
Fig. 5 is the flow chart that browser opens the page in the multi-page management method of the embodiment of the present invention two, such as Fig. 5 institute
Show, the process for opening the page can specifically include:
Step 510, browser receive page open request.
Step 520, browser state (i.e. cross-page face variable from the WebSocket constructed fuction that server receives cross-page face
Statement).
Whether step 530, the cross-page face variable management region of browser check the cross-page face variable (WebSocket)
By other page creations.If it is thening follow the steps 540;It is no to then follow the steps 550.
Step 540, cross-page face variable management region add the reference to WebSocket.
Wherein, the WebSocket in each cross-page face can be corresponding with one " reference counter ", when a page is clear
It lookes in device and opens and when the page refers to a WebSocket, the reference counter of the WebSocket can be added
"1".The adduction relationship of the mark of the page and WebSocket can also be deposited into cross-page face variable management region.
Step 550, in cross-page face variable management region, create the signalling path between the browser and server
(channel WebSocket);
Step 560 uses the channel WebSocket in open target pages.
Fig. 6 is the flow chart that browser closes the page in the multi-page management method of the embodiment of the present invention two, such as Fig. 6 institute
Show, the process for closing the page can specifically include:
Step 610, browser receive page close request.
Step 620 destroys the corresponding script running environment of the page (JavaScript Context).
Step 630 deletes reference of the page to WebSocket.
The reference counter of the corresponding WebSocket of the page can specifically be subtracted in cross-page face variable management region
" 1 " can also delete the mark and the adduction relationship of WebSocket by the page that cross-page face variable management region saves.
Step 640 checks whether the corresponding WebSocket of the page is quoted by other pages, if not by other pages
Reference, thens follow the steps 650.Wherein it is possible to according to the numerical value of the reference counter of the WebSocket, or according to preservation
The adduction relationship of the WebSocket and page iden-tity judge whether to be quoted by other pages.
Step 650 destroys the corresponding channel WebSocket the WebSocket.If the corresponding WebSocket of the page
It is quoted by other pages, is not then had to destroy the channel WebSocket, other pages can be waited to continue to use.
Wherein, it on the opportunity for creating and deleting the reference to the WebSocket in cross-page face, can be explicitly indicated by code, without
It is limited in and opens the page and closing page when progress.
For example, the statement of cross-page face shared variable is placed in the program block for being compiled and executing according to condition judgement,
Such as:
If (condition==true)
{
Var websocket=new WebSocket (' ws: //www.example.com ', [], name, [*]);//
Cross-page face shared variable is generated when eligible
}
The reference and generation of cross-page face variable in above procedure block, need to be in program process, according to preceding routine
The result dynamic of execution judges.In this case, creating and delete has two to the opportunity of the reference of the WebSocket in cross-page face
Kind method:
(1) adduction relationship is determined in page jump.In target pages load, the institute in cross-page face variable region is checked
Have cross-page face variable, if the scope of a certain cross-page face shared variable include target pages, then create target pages to this across
The reference of page shared variable.This method is the scope and target pages completion pressed cross-page face and share page variable, with
Code script and its implementing result in target pages is unrelated;
(2) in the code of parsing and the performance objective page, target is created again when encountering the statement of cross-page face shared variable
Reference of the page to the cross-page face shared variable.This method and by cross-page face share the scope of page variable, target pages,
Code script and its implementing result three in target pages is related.
Fig. 7 is the flow chart that browser page jumps in the multi-page management method of the embodiment of the present invention two, is jumped in the page
When turning, it is spaced for some time between the closing of the old page and the opening of target pages.In order to avoid in this time interval
The WebSocket in cross-page face is destroyed, and browser can receive page jump request, before executing old page close, sentences
Whether the URL of disconnected target pages belongs to the scope of some existing WebSocket, if it is, addition target pages are to this
The reference (reference of the target pages to the WebSocket is added i.e. before old page close) of WebSocket.As shown in fig. 7,
The process of page jump can specifically include:
Step 710, browser have already turned on current page, may refer to the process in Fig. 5, according to the cross-page face received
The constructed fuction of WebSocket is stated, creates the WebSocket to global variable management region, or increase to the WebSocket
Reference.
Step 720, browser receive page jump and request, execution step 730 and step 740, in the embodiment of the present invention not
The sequential relationship of conditioning step 730 and step 740, may be performed simultaneously, can also be successively.
Specifically, when user selects page jump or clicks the hyperlink of page jump, browser starts to process the page
Jump request.
The message that step 730, cache server are sended over by the channel WebSocket, to avoid information drop-out.
Step 740, browser are loaded the page resource of target pages by generalized flowsheet.
After completing loading page resource, step 750 can be executed.
Step 750, the scope for checking whether there is cross-page face variable (WebSocket) include target pages and target
Whether the page quotes the WebSocket, if so, thening follow the steps 760, otherwise may refer to step 550, in cross-page face variable
Management region creates the signalling path (channel WebSocket) between the browser and server.
The reference of step 760, addition to the WebSocket, it is then possible to referring to step 560, in open target pages
Use the channel WebSocket.
After completing target pages to the reference of the WebSocket, step 770 can be executed.
Step 770, the JavaScript Context for destroying the old page.
Step 780 deletes reference of the old page to the WebSocket.
Step 790, the page for currently showing browser are target pages by old page switching.
The JavaScript Context of step 791, the post-processing object page.
In the present embodiment, the example shared using WebSocket as cross-page face variable describes multi-page management method, but
It will be appreciated by those skilled in the art that the present invention answer it is without being limited thereto, such as: being not only applicable in the WebSocket conduct for cross-page face
The case where WebRTC signalling path, and the web scripting language (such as JavaScript) suitable for other web spheres provides
General cross-page face variable is shared.
When using other JavaScript variables as cross-page face variable, concrete methods of realizing can pass through modification
The constructed fuction statement (i.e. cross-page face variable declarations) of JavaScript variable is implemented, and can specifically modify are as follows:
Var variable1=new Variable (name1, ['/page2 ']);
Wherein, variable1 be the cross-page face variable variable name, name1 be the cross-page face variable shared name, ['/
Page2 '] it is target pages list.
Information can be shared and transmitted between multiple pages by the Variable.For example, user is in an electronics quotient
The Webpage of business is placed into an article in " shopping cart ", then branch to other pages with e-commerce website after
It is continuous to buy goods, there can be which inventory records to get off " shopping cart " of user is inner by cross-page face variable, in target pages
In can show.
In addition, in the network operating system (webos) of multithreading, need a thread keep user log-on message,
The authority information of user, user require the information when switching between multiple web programs, when between multiple pages share across
When the thread of the page, it can be convenient user and call user information at any time.When using other JavaScript thread variables as cross-page
When the variable of face, concrete methods of realizing can be stated by modifying the constructed fuction of JavaScript thread variable, can specifically be repaired
It is changed to:
Var variable1=new Thread (name2, ['/page2 ']);
Wherein, variable1 be cross-page face variable variable name, name2 be cross-page face variable shared name, ['/
Page2 '] it is target pages list.
The multi-page management method of the present embodiment, if there is the scope of cross-page face variable includes target pages, Ke Yi
Target pages add the reference to the cross-page face variable, share content using the corresponding page of cross-page face variable in target pages,
Resource-sharing can be realized by variable, reduce system resource waste.
For example, by sharing WebSocket, it is possible to reduce the WebSocket between client and the system of server is logical
The repetition in road connects, and can prevent that the channel WebSocket frequently disconnects and reconnection, realization are more during page jump
A page shares the channel WebSocket, saves system resource.It, can be in the different pages of client by sharing Variable
Between realize the transmitting of page info and shared, save system resource.By sharing thread (Thread), system money can be saved
Source.
Embodiment 3
Fig. 8 is the structural block diagram of the multi-page managing device of the embodiment of the present invention three, as shown in figure 8, the multi-page management
Device may include:
Searching module 81, for searching whether the scope of cross-page face variable according to the page jump request received
Including target pages;
Module 83 is quoted, is communicated with the searching module 81, in the scope packet for finding cross-page face variable
In the case where including target pages, the reference to the cross-page face variable is added for the target pages;
Sharing module 85 is communicated with the reference module 83, for being become in the target pages using the cross-page face
It measures the corresponding page and shares content.
Specifically, multi-page managing device can be realized by various forms of browsers in the embodiment of the present invention.If
Browser has currently had already turned on a certain page, and user's selection opens target pages in a browser or clicks a certain opening mesh
When marking the hyperlink of the page, browser can receive page jump request.It may include needing to jump in page jump request
The page info of the target pages gone to, such as: the identification information of target pages or hyperlink etc..Wherein, hyperlink can be
The URL pointer for including in html page, after user's clickable hyperlinks, browser can be from current page to mesh pointed by URL
Mark page jump.Wherein, the cross-page face variable in the embodiment of the present invention refers to that needs realize shared change between multiple pages
Amount, such as: WebSocket, Variable, the Thread etc. for needing cross-page face shared.The modules of multi-page managing device
The process of page jump may refer to the correlation of client in above-mentioned multi-page management method, the process that browser page jumps
Description.
In one possible implementation, the case where opening the page is being needed, the searching module 81 can be also used for
According to the page open request received, search whether that the scope of cross-page face variable includes target pages.Wherein, multi-page
The process that the modules of managing device open the page may refer to client in above-mentioned multi-page management method, browser is beaten
Open the associated description of the process of the page.
Multi-page managing device of the present invention, if the scope that searching module finds cross-page face variable includes page object
Face, reference module can add the reference to the cross-page face variable in target pages, and sharing module can be used in target pages
The corresponding page of cross-page face variable shares content, can pass through variable and realize resource-sharing, reduce system resource waste.
Embodiment 4
Fig. 9 is the structural block diagram of the multi-page managing device of the embodiment of the present invention four, as shown in figure 9, the multi-page management
Device can also include:
Removing module 91, for deleting and needing the page closed to described cross-page according to the page close request received
The reference of face variable;In the case where the searching module 81 finds the cross-page face variable and is not quoted by other pages, pin
It ruins the corresponding page of the cross-page face variable and shares content.Needing the case where closing the page, multi-page managing device it is each
The process that module closes the page may refer to client in above-mentioned multi-page management method, browser closes the process of the page
Associated description.
In one possible implementation, which can also include:
Receiving module 93, for receiving the cross-page face variable declarations of the target pages from server, the cross-page face becomes
Amount statement includes the title and scope of the corresponding cross-page face variable of the target pages, and the server is the target pages
Uniform resource position mark URL pointed by equipment, the title of the cross-page face variable includes variable name and/or shared name;
The searching module 81 is also used to the title according to the cross-page face variable, and the page that searches whether to have been friends in the past has built up
Cross-page face variable identical with the title of the cross-page face variable, and judge the scope of the cross-page face variable of the same name found
It whether include the target pages.
In one possible implementation, which can also include:
Read module 95, it is corresponding for reading the cross-page face variable from memory according to the variable name of the target pages
The page share content;
The reference module 83 is also used to update the numerical value in reference counter, or save the cross-page face variable with it is described
Adduction relationship between the identification information of target pages, the numerical value in the reference counter is for indicating the cross-page face variable
The number being currently cited.
In one possible implementation, the cross-page face variable needs common page info to be sharing for indicating
Variable, the sharing module 85 are specifically used for reading the corresponding page info of the page info variable in the target pages;
Or
The cross-page face variable needs thread variable to be sharing for indicating, the sharing module 85 is specifically used for described
Target pages run the corresponding thread of the thread variable;Or
The cross-page face variable is the signalling path variable for indicating to need to establish between server, the sharing module 85
Specifically for, using signalling path resource corresponding to the signalling path variable, being received from the server in the target pages
Send out data.
In one possible implementation, which can also include:
Loading module 97 is cached, for before searching whether that the scope of cross-page face variable includes target pages, if
The cross-page face variable is the thread that can generate or receive data, caches the data that the cross-page face variable generates or receives,
The target pages described in the loaded.
In one possible implementation, the removing module 91 can be also used for for the target pages addition pair
It after the reference of the cross-page face variable, is requested according to page jump, deletes the old page and the cross-page face variable is drawn
With;In the case where the searching module 81 finds the cross-page face variable and do not quoted by other pages, destroy described cross-page
The variable corresponding page in face shares content;Or
The removing module 91 is also used to after adding for the target pages to the reference of the cross-page face variable, is deleted
Except the old page to the reference of the cross-page face variable before, destroy the script running environment of the old page;It will currently show
The page switching shown is the target pages;Render the script running environment of the target pages.
Multi-page managing device of the present invention, if the scope that searching module finds cross-page face variable includes page object
Face, reference module can add the reference to the cross-page face variable in target pages, and sharing module can be used in target pages
The corresponding page of cross-page face variable shares content, can pass through variable and realize resource-sharing, reduce system resource waste.
Embodiment 5
Figure 10 is the structural block diagram of the multi-page managing device of the embodiment of the present invention five.The multi-page managing device 1100
It can be the host server for having computing capability, personal computer PC or portable portable computer or terminal etc..
The specific embodiment of the invention does not limit the specific implementation of calculate node.
The multi-page managing device 1100 includes processor (processor) 1110, communication interface
(Communications Interface) 1120, memory (memory) 1130 and bus 1140.Wherein, processor 1110,
Communication interface 1120 and memory 1130 pass through bus 1140 and complete mutual communication.
Communication interface 1120 is used for and network device communications, and wherein the network equipment includes such as Virtual Machine Manager center, is total to
Enjoy storage etc..
Processor 1110 is for executing program.Processor 1110 may be a central processor CPU or dedicated collection
At circuit ASIC (Application Specific Integrated Circuit), or it is arranged to implement the present invention
One or more integrated circuits of embodiment.
Memory 1130 is for storing file.Memory 1130 may include high speed RAM memory, it is also possible to further include non-
Volatile memory (non-volatile memory), for example, at least a magnetic disk storage.Memory 1130 is also possible to deposit
Memory array.Memory 1130 is also possible to by piecemeal, and described piece can be combined into virtual volume by certain rule.
In a kind of possible embodiment, above procedure can be the program code for including computer operation instruction.The journey
Sequence is particularly used in:
According to the page jump request received, search whether that the scope of cross-page face variable includes target pages;
In the case where finding the scope of cross-page face variable includes target pages, for target pages addition pair
The reference of the cross-page face variable;
The corresponding page of the cross-page face variable is used to share content in the target pages.
In a kind of possible embodiment, above procedure can also be used to be searched according to the page open request received
The scope for whether having cross-page face variable includes target pages.
In a kind of possible embodiment, above procedure can also be used to be deleted according to the page close request received
Reference of the page for needing to close to the cross-page face variable;
Search whether the cross-page face variable is quoted by other pages;
In the case where the cross-page face variable is not quoted by other pages, the corresponding page of the cross-page face variable is destroyed
Shared content.
In a kind of possible embodiment, search whether that the scope of cross-page face variable includes target pages, comprising:
The target pages are received from server, include cross-page face variable declarations in the procedure script of the target pages,
The cross-page face variable declarations include the title and scope of the corresponding cross-page face variable of the target pages, and the server is
Equipment pointed by the uniform resource position mark URL of the target pages, the title of the cross-page face variable include variable name and/
Or shared name;
According to the title of the cross-page face variable, the page that searches whether to have been friends in the past has built up the name with the cross-page face variable
Claim identical cross-page face variable, and judges whether the scope of the cross-page face variable of the same name found includes the page object
Face.
In a kind of possible embodiment, the reference to the cross-page face variable is added for the target pages, comprising:
Update the numerical value in reference counter, or save the cross-page face variable and the target pages identification information it
Between adduction relationship, the numerical value in the reference counter is for indicating the number that the cross-page face variable is currently cited;
It is corresponding that the cross-page face variable is read from memory according to the title of the corresponding cross-page face variable of the target pages
The page share content.
In a kind of possible embodiment, the cross-page face variable needs common page info to be sharing for indicating
Variable uses the corresponding page of the cross-page face variable to share content, comprising: to read in the target pages in the target pages
Take the corresponding page info of the page info variable;Or
The cross-page face variable needs thread variable to be sharing for indicating, uses the cross-page face in the target pages
The corresponding page of variable shares thread, comprising: runs the corresponding thread of the thread variable in the target pages;Or
The cross-page face variable is the signalling path variable for indicating to need to establish between server, in the target pages
Content is shared using the corresponding page of the cross-page face variable, comprising: uses the signalling path variable in the target pages
Corresponding signalling path resource, from the server sending and receiving data.
In a kind of possible embodiment, for target pages addition to the reference of the cross-page face variable it
Afterwards, comprising:
It is requested according to page jump, deletes reference of the old page to the cross-page face variable;
Search whether the cross-page face variable is quoted by other pages;
In the case where the cross-page face variable is not quoted by other pages, the corresponding page of the cross-page face variable is destroyed
Shared content.
In a kind of possible embodiment, for target pages addition to the reference of the cross-page face variable it
Afterwards, before deleting the old page to the reference of the cross-page face variable, comprising:
Destroy the script running environment of the old page;
It is the target pages by the page switching currently shown;
Render the script running environment of the target pages.
In a kind of possible embodiment, search whether the cross-page face variable is quoted by other pages, comprising:
According to the numerical value of the corresponding reference counter of the cross-page face variable, determine the cross-page face variable whether by other
Page reference;Or
According to the adduction relationship between the cross-page face variable and the identification information of the target pages, determine described cross-page
Whether face variable is quoted by other pages.
The embodiment of the present invention can be added if there is the scope of cross-page face variable includes target pages in target pages
Reference to the cross-page face variable shares content using the corresponding page of cross-page face variable in target pages, can pass through variable
It realizes resource-sharing, reduces system resource waste.
Those of ordinary skill in the art may be aware that each exemplary cell and algorithm in embodiment described herein
Step can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions actually with hardware also
It is software form to realize, the specific application and design constraint depending on technical solution.Professional technician can be directed to
It is specific that described function is realized using different methods is selected, but this realization is it is not considered that exceed model of the invention
It encloses.
If realizing the function and when sold or used as an independent product in the form of computer software,
To a certain extent it is believed that all or part (such as the part that contributes to existing technology) of technical solution of the present invention is
It embodies in form of a computer software product.The computer software product is generally stored inside computer-readable non-volatile
In storage medium, including some instructions are used so that computer equipment (can be personal computer, server or network to set
It is standby etc.) execute all or part of the steps of various embodiments of the present invention method.And storage medium above-mentioned include USB flash disk, mobile hard disk,
Read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic
The various media that can store program code such as dish or CD.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.