The page attribute smartnavigation is very interesting. He can simulate a very smooth "no refreshing" page without modifying the page element layout, why is this "no matter what the new" is? In fact, he refresh the page, and does not use XMLHTTP or xmldom technology. It is actually a submit. Maybe this is something about browser compatibility.
The implementation principle of smartnavigation is similar to the double buffering technology we use in animation rendering. First, let's talk about his transformation to a common page. He adds two lines to the returned results of a common. ASPX page. Code , One is IFRAME, and the other is a JScript:
...
< IFRAME ID = "_ Hifsmartnav" Name = "_ Hifsmartnav" Style = "Display: none"
SRC = "/Aspnet_client/system_web/2017100004322/smartnav.htm" > </ IFRAME >
...
<ScriptLanguage= "Jscript"SRC= "/Aspnet_client/system_web/zookeeper 4322/smartnav. js"> </Script>
...
The IFRAME (_ hifsmartnav) in the middle is equivalent to the actual drawing surface in animation drawing. In smart navigate, it is the actual submit page and data receiving page. All of this is smartnav. A masterpiece of JS, smartnav. JS uses a more interesting technology. In fact, it is an old technology that cannot be used any more. In modern words, it is a hook. In other words, it is just the same as modifying the interrupt vector in DOS. How does it work? In fact, in addition to the display output, all operations are cloned into IFRAME for execution, because the IFRAME object has the greatest similarity with the document object, including attributes and events.
When we execute the Enable page for smartnavigation, it is first accessed by smartnav. JS guide. The most critical sentence in this script is: var rc = Window. _ smartnav. attachform ();, whose role is to wrap the form on our current page into a class named _ smartnav, and then use this class to perform all navigate operations.
This is the most important and exciting code in smartnav. JS:
If (Snfm. _ formattached = True ) Return True ;
Snfm. _ formattached = True ;
Snfm. attachevent ( " Onsubmit " , Window. _ smartnav. init );
Snfm. _ submit = Snfm. Submit;
Snfm. Submit = Window. _ smartnav. Submit;
Snfm.tar get = Window. _ smartnav. hifname;
He completed the form attach and hooked the page's submit event, in the last sentence, set the target of form in _ smartnav to _ hifsmartnav (this is the hidden IFRAME ). If the target is not changed, submit submits the current form.
There is nothing to say here. Commit is executed by _ hifsmartnav, and the returned data is returned to this IFRAME, the rest is to write the obtained data back to our original document. The code is complicated and there are many processing situations. Even the title update is taken into account, if you are interested, read it by yourself.