Lightweight modal box solution implemented by JavaScript (Ajax supported)

Source: Internet
Author: User

Many solutions for implementing modal boxes can be found on the Internet, but most of them need to introduce JavaScript libraries such as jquery, mootools, dojo, and Yui. It would not be worth the candle if we only want to introduce a large class library to implement the modal box. Here we provide you with a lightweight modal box solution tinybox implemented using JavaScript.

A modal box pops up a subwindow on the current page. If the subwindow is not closed, the parent window function cannot be operated.

Let's take a look at the online example of this solution:Online browsing example

Author's homepage (author website ):Http://www.leigeber.com

Tinybox features:

    1. Tinybox is an independent modal box script, which does not need to be introduced into other script libraries.
    2. Tinybox is a lightweight modal box script with a compressed version of only 3.5 kb.
    3. The pop-up modal box can call HTML content or call other pages through Ajax.
    4. You can call this operation to display images.
    5. The modal box is automatically closed after a certain period of time.
    6. Determines whether to enable the load loading flag when the modal box is opened.
    7. The size of the modal box can be controlled, or the adaptive size can be selected based on the content of the modal box
    8. You can use simple CSS to control the modal box style.
    9. This script is successfully tested in Firefox 2/3, ie 6/7/8, opera, Safari and chrome.

How to Use tinybox:

    1. The first step is to introduce the tinybox script file and style first.
    2. Use the following statement to call the modal box:
      Tiny.box.show('advanced.html ', 1,300,150, 1, 3)
    3. Tiny. Box. Show parameter explanation:
      The first advanced.html is to call the content. If Ajax calls a page, the relative path of the page is written; If HTML content is called, the JavaScript Object is input;
      The second parameter 1 is used to identify whether the page is called through Ajax. The value is 1 and the value is 0;
      The third parameter is 300, which is used to control the window width of the pop-up modal box. If the value is 0, the parameter is auto-adaptive;
      The fourth parameter is 150, which is used to control the window height of the pop-up modal box. If 0 is used, auto Auto Adaptive is used;
      The fifth parameter 1 is used to control whether the loading ID is displayed. 1 is enabled, and 0 is not enabled;
      Parameter 6 3: The modal box window is automatically closed after three seconds of identification. this parameter is optional. If this parameter is not set, it is not automatically closed.

Other Instructions:

    1. Source of this solution:SourceIf you have any questions, contact the author on the source homepage, or leave a message on this page for discussion.
    2. The author said that new features will be introduced in the next version, and we look forward to them together.

Download sample source code:Lightweight modal box solution implemented by JavaScript[Size: 38.32 KB-downloads: 178]

Related Article

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.