JSON Reference Application

Source: Internet
Author: User
Tags close close

JSON Reference Application

JSON (JavaScript Object Notation) is a lightweight data interchange format. JSON takes a completely language-independent text format, which makes JSON an ideal data exchange language. Easy to read and write, but also easy to machine parse and generate.

The following is a simple pop-up widget that changes the style of the pop-up window by using JSON parameters.


 <  button  id  = "Open"  >  open </ button  >  <  button  id  = "Close"  >  close </ button  >  <  div  id  = "box"  ></ div  >  


functionAlert (JSON) { This. Win=document.getelementbyid (' box ');  This. w=json.width| | 200; //If the parameter is ' ', it is displayed.          This. h=json.height| | 150;  This. content=json.content| | ' Box;  This. win.style.height= This. H + ' px ';  This. win.style.width= This. w+ ' px ';  This. win.innertext= This. Content;  This. win.style.background=json.background| | ' Black;  This. win.style.color=json.color| | ' White; } Alert.prototype.open=function() {// object prototype, open          on Close close This. win.style.display= ' Block '; } Alert.prototype.close=function(){         This. win.style.display= ' None '; }

Call JS:

Window.onload=function(){     varOpen=document.getelementbyid (' Open '); varClose=document.getelementbyid (' Close '); varbox=NewAlert ({height:100, Width:100, Content:' Pop the window ', background:' Red ', Color:' Blue '    }); Open.onclick=function() {box.open ();    }; Close.onclick=function() {Box.close ()}};

JSON Reference Application

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.