Ajax local Fetch template--perfect window hiding and co-use

Source: Internet
Author: User

Ajax can also take templates locally, examples-perfect window hiding and co-use, simple sample template code in the Templates folder

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Local fetch template--perfect window hiding and co-use</title>    <style>. Add{width:300px;Background-color:Gray;        }ul{List-style:None;        }    </style></Head><Body>    <ul>        <Li>Open it<inputtype= "button"ID= "Open"></Li>        <Li>Browse<inputtype= "button"ID= "Look"></Li>         </ul></Body><Script>    vargethtml=function(URL,FN) {varXHR= NewXMLHttpRequest (); Xhr.open ("GET", URL); Xhr.setrequestheader ("Content-type", "Text/plain"); Xhr.onreadystatechange= function() {            if(Xhr.readystate== 4) {fn (xhr.responsetext); }} xhr.send (NULL); }    //Open Window One    varOpen=document.getElementById ("Open"); Open.onclick=function() {gethtml ("template/add.html",function(HTML) {varDialog=Document.createelement ("Div"); Dialog.innerhtml=html;            Document.body.appendChild (Dialog); varwords=document.getElementById ("words"); Words.setattribute ("Status","Open"); //Setting PropertiesWords.innertext="haaaaaaaa";           Bind_event (); //open the execution of various operation functions in the window        }); }    //Open Window two    var Look=document.getElementById (" Look"); Look.onclick=function() {gethtml ("template/add.html",function(HTML) {varDialog=Document.createelement ("Div"); Dialog.innerhtml=html;        Document.body.appendChild (Dialog); varwords=document.getElementById ("words"); Words.setattribute ("Status"," Look"); Words.innertext="XIIIIIIII";           Bind_event ();    }); }    //Exit    varbind_event=function(){        varExit=document.getElementById ("Exit"); Exit.addeventlistener ("Click",function() {             This. ParentNode.parentNode.removeChild ( This. parentnode); } )    }</Script></HTML>

Template folder

<Divclass= "Add">    <Pclass= "Words"ID= "Words"></P>    <inputtype= "button"value= "Exit"ID= "Exit"></Div>

Ajax local Fetch template--perfect window hiding and co-use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.