On the beautification _javascript skills of JavaScript alert and confirm

Source: Internet
Author: User
Tags function prototype

--The preface--

The alert and confirm standard methods for window objects do not display the same in different browsers, and there is a common point that is not very attractive. Our idea is to use JS and CSS to imitate them, to provide another set of functions, so that in different browsers have the same experience effect.

--Design idea--

To preserve the original alert and confirm methods, instead of directly replacing alert and confirm for the Window object, we create a new win object with alert, confirm, open, close, and so on. Win.alert, etc. dialog box pop-up layer, using the IFRAME as the bottom layer, make sure that the dialog box can also overwrite the select label at the bottom when the IE7 is ejected, and that the script will not block when it pops up, so functions like Win.alert provide a callback parameter that triggers the dialog box when it is closed or selected. Callback parameter, the function prototype is as follows:

Win.alert = function (title, message, closed) {...}//alert
win.confirm = function (title, message, selected) {...} Confirm
Win.open = function (width, height, title, URL, closed) {...}//pop-up page dialog box

--the results show--

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, but also hope that a lot of support cloud Habitat community!

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.