js----------artdialog(复制别人的,不过挺好)

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>webrx</title>
    <script src="artDialog/artDialog.js?skin=chrome"></script>
</head>
<body>
<script>
    /**
     * 警告
     * @param	{String}	消息内容
     */
    artDialog.alert = function (content, callback) {
        return artDialog({
            id: 'Alert',
            icon: 'warning',
            fixed: true,
            lock: true,
            content: content,
            ok: true,
            close: callback
        });
    };


    /**
     * 确认
     * @param	{String}	消息内容
     * @param	{Function}	确定按钮回调函数
     * @param	{Function}	取消按钮回调函数
     */
    artDialog.confirm = function (content, yes, no) {
        return artDialog({
            id: 'Confirm',
            icon: 'question',
            fixed: true,
            lock: true,
            opacity: .1,
            content: content,
            ok: function (here) {
                return yes.call(this, here);
            },
            cancel: function (here) {
                return no && no.call(this, here);
            }
        });
    };


    /**
     * 提问
     * @param	{String}	提问内容
     * @param	{Function}	回调函数. 接收参数:输入值
     * @param	{String}	默认值
     */
    artDialog.prompt = function (content, yes, value) {
        value = value || '';
        var input;

        return artDialog({
            id: 'Prompt',
            icon: 'question',
            fixed: true,
            lock: true,
            opacity: .1,
            content: [
                '<div style="margin-bottom:5px;font-size:12px">',
                content,
                '</div>',
                '<div>',
                '<input value="',
                value,
                '" style="width:18em;padding:6px 4px" />',
                '</div>'
            ].join(''),
            init: function () {
                input = this.DOM.content.find('input')[0];
                input.select();
                input.focus();
            },
            ok: function (here) {
                return yes && yes.call(this, input.value, here);
            },
            cancel: true
        });
    };


    /**
     * 短暂提示
     * @param	{String}	提示内容
     * @param	{Number}	显示时间 (默认1.5秒)
     */
    artDialog.tips = function (content, time) {
        return artDialog({
            id: 'Tips',
            title: false,
            cancel: false,
            fixed: true,
            lock: true
        })
            .content('<div style="padding: 0 1em;">' + content + '</div>')
            .time(time || 1);
    };
</script>
<input type="button" value="提示" onclick="art.dialog('你好')"><br>
<input type="button" value="artdialog(欢迎欢迎)" onclick="art.dialog.alert('欢迎欢迎')"><br>

<br>
<a href="javascript:void(0)" onclick="art.dialog.prompt('请输入年龄',null,18)">请输入年龄</a>
</body>
</html>

结果如下:

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值