A kind of URL parameter dynamically recording loading method of no refreshing
Technical field
The present invention relates to front end development technique field, the URL parameter dynamically recording of especially a kind of no refreshing is loaded
Method.
Background technique
The development of software and hardware and front-end technology in recent years, for meet the good interface alternation demand of user it is various with
Front end is that the rich application program of center of gravity continuously emerges.The characteristics of this rich application is good interaction response, and interface is using asynchronous
Local hydrodynamic unit form (only update the part of user's operation, remaining certain customers can continue normal browsing, that is,
Ajax technology), usually using using javascript as the response mode of center of gravity.
Many scene users need the interface to other user's sharing operations interface, and traditional mode is by a system
Screenshot is carried out to final operating result after the operation of column and is shared with other users, other users can not from static picture
The enjoyment that rich application program interactive mode brings him is obtained, and he can not obtain other letters other than current operation result
Breath.
Therefore, a kind of user embodies good intuitive interface sharing method and seems very necessary.
Summary of the invention
Present invention solves the technical problem that being to provide a kind of method of the URL parameter dynamically recording load of no refreshing;Have
Effect solves the problem above-mentioned, and provides a kind of user's embodiment good intuitive interface sharing method.
The technical solution that the present invention solves above-mentioned technical problem is:
The method is to write oracle listener using javascript, record and move result to crucial operation
State is recorded in URL, is dynamically modified by the object of location.hash, is used #param1=value1¶m2=
The form dynamically recording of value2 is in URL;Front end URL of the parsing with operating parameter simultaneously reappears operation interface, allows user
Easily share current operation interface.
The method at the parsing URL reproduction process interface of the method is:
Code is write using javascript, page loaded obtains location.hash character string and is parsed into
Json data reappear interface according to json data.
User's operation process is:
User A accesses rich application program in environment A and has carried out several operations, and user A will have recorded current behaviour
The URL for making state is shared with user B, and user B directly accesses rich application program, Fu Yingyong using the URL that A is provided in environment B
Program can reappear the operating result of A to B according to parameter.
The specific implementation flow of the method is:
The first step writes parsing and the logic of location.hash is arranged:
Resolution logic: if location.hash is not sky, json form is converted by location.hash;
Logic is arranged: there is no the values in the json data of hash, then are added in json;It, will in the presence of then assignment again
Json changes into the form of location.hash, and changes location.hash;
Second step writes reference record program: corresponding event monitoring is write in needing the operation recorded, user is actively
Corresponding event is triggered, then the value of location.hash is arranged in the parsing setting logic write using the first step;
Third step writes state reduction logic: in page loaded, if accessing this program using the URL with anchor point
The parsing code analysis then write using the first step restores interface according to current json data at json data.
The present invention uses the form without refreshing by the operation note of user in URL in front end, and user can easily share
Current operation interface gives other people, and front end URL of the parsing with operating parameter simultaneously reappears operation interface, can easily share boundary
Face.Present invention is especially suited for the rich applications for paying attention to user's embodiment, such as the fields such as the interaction of AJAX request data, map and chart interaction
It closes.User can be recorded in URL anchor point the operation of front-end interface, and complete URL need to be only shared with other uses by user
Person, so that it may realize and share interface.
Detailed description of the invention
The following further describes the present invention with reference to the drawings:
Fig. 1 is detailed process of the present invention.
Specific embodiment
As shown in Figure 1, the specific embodiment of the invention is as follows:
The first step writes parsing and the logic of location.hash is arranged:
Resolution logic: if location.hash is not sky, json form, code are converted by location.hash
It is as follows:
Logic is arranged: there is no the values in the json data of hash, then are added in json, there is then assignment again, will
Json changes into the form of location.hash, and changes location.hash, and code is as follows:
Second step writes reference record program: corresponding event monitoring is write in needing the operation recorded, user is actively
Corresponding event is triggered, then the value of location.hash is arranged in the parsing setting logic write using the first step.Event monitoring
Logic it is almost the same, the global variable of default is configured after user triggers corresponding event, is recalled unified
Graphic hotsopt interface is presented interface, and only the event monitoring of service index selection illustrates that code is as follows below:
// monitor simultaneously record index selection
$(″.submenu a″).click(function(){
Cur_report=this.getAttribute (' report-index ');
loadData(cur_report,cur_area,cur_type);
});
Unified setting location.hash, code are as follows in the interface of graphic hotsopt:
Third step writes state reduction logic: in page loaded, if accessing this program using the URL with anchor point
The parsing code analysis then write using the first step restores interface according to current json data, generation at json data
Code is as follows: