A kind of test method and test device that can judgement surf the Internet
Technical field
The present invention relates to network test field, the test method that can be surfed the Internet more particularly to a kind of judgement and test dress
It sets.
Background technique
All be mostly in the prior art inside the cgi (Common Gateway Interface, CGI(Common gateway interface)) into
Row judgement can surf the Internet, and then in the value for returning to page response, the page goes to judge in the value returned by cgi, Jin Erxian
Show corresponding page effect, this interaction needs to take some time, and needs bottom and front end during debugging
It goes cooperation to debug, while having many limitations, such as the speed read, the problems such as the accuracy of judgement, and need page
The interaction process in face and cgi, it is fairly cumbersome, especially for developer, if be not all very familiar with to bottom and front end
Words are encountered problem and are difficult to where orientation problem promptly and accurately.
Summary of the invention
Can the object of the present invention is to provide one kind not to need cgi processing, directly judge surf the Internet by JavaScript
Test method and test device, accurate quick.
Technical solution provided by the invention is as follows:
The present invention discloses a kind of test method that can judgement surf the Internet, and services comprising steps of being accessed by JavaScript
The particular picture of device;When receiving when returning the result of particular picture described in successful access, then judge that current network can surf the Internet.
The invention also discloses the test methods that can another judgement surf the Internet, comprising steps of being visited by JavaScript
Ask the particular picture of server;When receiving when returning the result of particular picture described in successful access, then judge that current network can
With online.If when returning the result of the particular picture can not be accessed by receiving, within a preset time according between preset time
Access request is initiated to server every lasting.
The invention also discloses the test methods that can another judgement surf the Internet, comprising steps of being visited by JavaScript
Ask the particular picture of server;When receiving when returning the result of particular picture described in successful access, then judge that current network can
With online.If when returning the result of the particular picture can not be accessed by receiving, within a preset time according between preset time
Access request is initiated to server every lasting.The return of particular picture described in successful access is not received in the preset time
When as a result, then request timed out, judges that current network be cannot get online.
It is further preferred that the display page is dynamic effect when judging that current network can surf the Internet.
It is further preferred that the display page is static effects when judging that current network be cannot get online.
The invention also discloses the test devices that can a kind of judgement surf the Internet, comprising: access modules pass through JavaScript
Access the particular picture of server;Judgment module then judges when receiving when returning the result of particular picture described in successful access
Current network can surf the Internet.
The invention also discloses the test devices that can another judgement surf the Internet, comprising: access modules pass through
The particular picture of JavaScript access server;Judgment module, when the return knot for receiving particular picture described in successful access
When fruit, then judge that current network can surf the Internet.The return knot of the particular picture can not be accessed when the judgment module receives
When fruit, the access modules continue to initiate access request to server within a preset time according to prefixed time interval.
The invention also discloses the test devices that can another judgement surf the Internet, comprising: access modules pass through
The particular picture of JavaScript access server;Judgment module, when the return knot for receiving particular picture described in successful access
When fruit, then judge that current network can surf the Internet.The return knot of the particular picture can not be accessed when the judgment module receives
When fruit, the access modules continue to initiate access request to server within a preset time according to prefixed time interval.When described
Judgment module does not receive when returning the result of particular picture described in successful access within a preset time, judges that current network cannot
Online.
The invention also discloses the test devices that can another judgement surf the Internet, comprising: access modules pass through
The particular picture of JavaScript access server;Judgment module, when the return knot for receiving particular picture described in successful access
When fruit, then judge that current network can surf the Internet;The return knot of the particular picture can not be accessed when the judgment module receives
When fruit, the access modules continue to initiate access request to server within a preset time according to prefixed time interval;When described
Judgment module does not receive when returning the result of particular picture described in successful access within a preset time, judges that current network cannot
Online;Display module, when judging that current network can surf the Internet, the display page is dynamic effect;And when judging current network
When cannot get online, the display page is static effects.
Compared with prior art, the present invention accesses the particular picture above server by JavaScript, and constantly
Hair access request is gone, particular picture can be found and be judged as and can surf the Internet, is otherwise exactly that cannot surf the Internet, and set each
The time interval and total degree of request, facilitate whole control, directly judge whether to surf the Internet by JavaScript, not need
It goes to handle by cgi, be judged by front-end code, judgment accuracy is higher, judges that the time faster, facilitates modification and maintenance.
Detailed description of the invention
Below by clearly understandable mode, preferred embodiment is described with reference to the drawings, can surf the Internet to a kind of judgement
Above-mentioned characteristic, technical characteristic, advantage and its implementation of test method and test device are further described.
Fig. 1 is a kind of step schematic diagram for the test method that can judgement surf the Internet of the present invention;
Fig. 2 is a kind of main composition schematic diagram for the test device that can judgement surf the Internet of the present invention;
Fig. 3 is fully composed schematic diagram for a kind of test device that can judgement surf the Internet of the present invention.
Drawing reference numeral explanation:
100. access modules, 200. judgment modules, 300. display modules.
Specific embodiment
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, Detailed description of the invention will be compareed below
A specific embodiment of the invention.It should be evident that drawings in the following description are only some embodiments of the invention, for
For those of ordinary skill in the art, without creative efforts, it can also be obtained according to these attached drawings other
Attached drawing, and obtain other embodiments.
To make simplified form, part related to the present invention is only schematically shown in each figure, they are not represented
Its practical structures as product.In addition, there is identical structure or function in some figures so that simplified form is easy to understand
Component only symbolically depicts one of those, or has only marked one of those.Herein, "one" is not only indicated
" only this ", can also indicate the situation of " more than one ".
Fig. 1 is a kind of step schematic diagram for the test method that can judgement surf the Internet of the present invention, as a tool of the invention
Body embodiment, as shown in Figure 1, the test method that can a kind of judgement surf the Internet, services comprising steps of being accessed by JavaScript
The particular picture of device;When receiving when returning the result of particular picture described in successful access, then judge that current network can surf the Internet.
Specifically, must be fixed in the present invention by the name and path of the particular picture of JavaScript access, it can not
With change.
Above-described embodiment is improved, the test method that can another judgement surf the Internet is obtained, comprising steps of passing through
The particular picture of JavaScript access server;When receiving when returning the result of particular picture described in successful access, then sentence
Disconnected current network can surf the Internet.If when returning the result of the particular picture can not be accessed by receiving, press within a preset time
Continue to initiate access request to server according to prefixed time interval.
Specifically, the number and prefixed time interval of access request oneself can be set in the present invention, it is easy to use not
With on the page.
Above-described embodiment is improved, the test method that can another judgement surf the Internet is obtained, comprising steps of passing through
The particular picture of JavaScript access server;When receiving when returning the result of particular picture described in successful access, then sentence
Disconnected current network can surf the Internet.If when returning the result of the particular picture can not be accessed by receiving, press within a preset time
Continue to initiate access request to server according to prefixed time interval.Spy described in successful access is not received in the preset time
Determine when returning the result of picture, then request timed out, judges that current network be cannot get online.
The present invention mainly calls a function before this, this function can go the particular picture above access server, so
Afterwards if particular picture can be accessed, it is returned to returning the result for particular picture described in success i.e. successful access, cannot be accessed
Particular picture, returning the result for the particular picture can not be accessed by being returned to error, never be accessed within a preset time
Timeout request timed out result is returned to particular picture.It then respectively can be just to the page according to the Different Results of return
Corresponding processing.
Preferably, when judging that current network can surf the Internet, the display page is dynamic effect.
Preferably, when judging that current network be cannot get online, the display page is static effects.
The present invention shows corresponding effect in the page according to judging result, easily and intuitively allow user know whether can more than
Net.
Fig. 2 is a kind of main composition schematic diagram for the test device that can judgement surf the Internet of the present invention, as of the invention one
A specific embodiment, as shown in Figure 2, comprising: access modules 100 access the particular picture of server by JavaScript;Sentence
Disconnected module 200 then judges that current network can surf the Internet when receiving when returning the result of particular picture described in successful access.
Above-described embodiment is improved, obtains the test device that can another judgement surf the Internet, comprising: access modules
100, the particular picture of server is accessed by JavaScript;Judgment module 200, when receiving specific pattern described in successful access
When returning the result of piece then judges that current network can surf the Internet.When the judgment module 200 receive can not access it is described specific
When returning the result of picture, the access modules 100 continue to initiate to server according to prefixed time interval within a preset time
Access request.
Above-described embodiment is improved, obtains the test device that can another judgement surf the Internet, comprising: access modules
100, the particular picture of server is accessed by JavaScript;Judgment module 200, when receiving specific pattern described in successful access
When returning the result of piece then judges that current network can surf the Internet.When the judgment module 200 receive can not access it is described specific
When returning the result of picture, the access modules 100 continue to initiate to server according to prefixed time interval within a preset time
Access request.When the judgment module 200 does not receive returning the result for particular picture described in successful access within a preset time
When, judge that current network be cannot get online.
Above-described embodiment is improved, the test device that can another judgement surf the Internet is obtained, Fig. 3 is that the present invention is a kind of
Can judge the test device that surf the Internet be fully composed schematic diagram, as shown in Figure 3, comprising: access modules 100 pass through
The particular picture of JavaScript access server;Judgment module 200, when the return for receiving particular picture described in successful access
When as a result, then judge that current network can surf the Internet;Returning for the particular picture can not be accessed when the judgment module 200 receives
When returning result, the access modules 100 continue to initiate access request to server within a preset time according to prefixed time interval;
When the judgment module 200 does not receive when returning the result of particular picture described in successful access within a preset time, judgement is worked as
Preceding network be cannot get online;Display module 300, when judging that current network can surf the Internet, the display page is dynamic effect;And
When judging that current network be cannot get online, the display page is static effects.
It should be noted that above-described embodiment can be freely combined as needed.The above is only of the invention preferred
Embodiment, it is noted that for those skilled in the art, in the premise for not departing from the principle of the invention
Under, several improvements and modifications can also be made, these modifications and embellishments should also be considered as the scope of protection of the present invention.