Objective
Recently in the SPRINGMVC integration of a JSP-based reporting tool, after integration, due to the large number of report calculations, SQL statements more complex, so the foreground click button Trigger, after a few seconds to react to pop up the report box, so want to join a similar loading in a good hint, so that the customer experience better , but not as easy as it is, the main product used by the Freemarker template engine, loading the encapsulated dialog method can not directly access the page and can not directly to the page and so on, but the problem is I one by one solved, nonsense not to say, directly into the topic, mainly to see the simple implementation of this small function.
Introduce the following HTML element
<body><div style= "width:100%!important;height:850px;text-align:center;" ><div id= "Loading" style= "margin-top:200px;" ><p><br/><font style= " Height:30px;vartical-algin:center;padding-left:5px "> is in the statistics, please wait a moment ......</font></p></div>< iframe id= "Reportiframe" src= "" frameborder= "no" border= "0" marginwidth= "0" marginheight= "0" scrolling= "yes" width= " 100% "height=" 100% "></iframe></div></body>
Of course, mine is based on the components encapsulated in this project, you can not need the outer div or do not need to directly limit the height and so on.
Js/jquery Key Code
$ (function () {var frameurl= "The path of the page to load in frame"; $ ("#reportIframe"). attr ("src", Frameurl); $ ("#reportIframe"). Load ( function () {//jquery control ' load ' div does not display $ ("#loading"). CSS ("display", "none");});
Effect
Postscript
If you carefully read, it is, is not perfect, waiting for the words and pictures should be floating in the content of the IFRAME is good, so that the IFRAME loading over the process and "loading" the words and pictures too much is very moderate, and then "loading" The words and pictures can be positioned directly in the center of the pop-up box instead of using margin,padding and other styles to locate otherwise different resolutions, may not be the same.
The above shortcomings really need to improve, because I have limited time and energy, the project is tight, so no longer pursue the higher quality of the function, if you are reading the article, have the time to have the ability to study out, very welcome to your message to answer, so you, me, and we have common progress and learning!
Loading in-js/jquery feature implementation