js手机端浮层控件,并有多种弹出小提示,兼容pc端浏览器

js dialog组件,包含alert和confirm的实现

本组件所有的资源均在github上可以查看源代码 GitHub

本dialog的组件的例子请在这里查看 demo

dialog

js dialog弹窗

用法

这是内容

<input type="button" id="btn_dialog" value="打开浮层"/>
<div id="dialog-content" style="display:none;">这是内容</div>
<script src="../src/jquery-1.9.1.min.js"></script>
<script src="../src/dialog.js"></script>
<script>
    var dialog = new Dialog();
    dialog.init({target:"#dialog-content",trigger:"#btn_dialog",mask:true,width:500,height:300,title:‘标题‘});
</script>

或者用jquery方式调用:

<input type="button" id="btn_dialogjquery" value="jq打开浮层"/>
<div id="dialog-contentjq" style="display:none;">这是内容22</div>
<script src="../src/dialog-jquery.js"></script>
<script>
    $(‘#btn_dialogjquery‘).Dialog({target:"#dialog-contentjq",mask:true,width:500,height:300,title:‘标题‘})
</script>
    

继承类alert和confirm提示(jquery模式下):

   *html:
    <input type="button" id="btn_alert" value="alert"/>
    <input type="button" id="btn_alert2" value="alert定时关闭"/>
    <input type="button" id="btn_confirm" value="confirm三种按钮"/>
    <input type="button" id="btn_confirmdefault" value="confirm默认"/>
    *js:
    $(‘#btn_alert‘).click(function(){
        $.alert(‘选好商品才能上传素材哦‘,true,function(){
            alert(‘你点击了ok‘)
        })
    });
    $(‘#btn_alert2‘).click(function(){
        $.alert(‘选好商品才能上传素材哦‘)
    });
    $(‘#btn_confirm‘).click(function(){
        $.confirm(‘下载全部 9 张图片至本地相册?<div class="confirm-title2">文字内容已复制</div>‘,[{yes:"是"},{no:‘否‘},{close:‘关闭‘}],function(type){
            $.alert(‘您点击了‘+type);
            this.hide();
        });
    })
    $(‘#btn_confirmdefault‘).click(function(){
        $.confirm(‘你确定要删除这条消息吗? ‘,null,function(type){
            $.alert(‘您点击了‘+type);
            this.hide();
        });
    })

属性或方法

属性

trigger:

    触发对象
	

target:

    弹出内容,可以为#id,或者jquery对象
	

mask:

    是否有遮罩层
	

title:

    标题
	

zIndex:

    z-index
	

closeTpl:

    关闭html(默认:<span class="ui-dialog-close js-dialog-close">x</span>)
	

titleTpl:

    标题html(默认:<div class="ui-dialog-title"></div>)
	

方法及回调

show:

    显示弹层
	

hide:

    隐藏
	

beforeShow:function(content)

    显示前的方法回调,content是浮层内容对象
	

beforeHide:function(content)

    隐藏前的方法回调,content是浮层内容对象
	

setPosition:function()

    设置位置居中
	
时间: 2024-12-19 05:30:32

js手机端浮层控件,并有多种弹出小提示,兼容pc端浏览器的相关文章

mobiscroll 控件的使用(手机端日历控件)

先上一张图吧: 控件的下载地址:http://www.kuitao8.com/20140604/2615.shtml 文档API地址:http://docs.mobiscroll.com/2-13-2/datetime#!opt-minDate 网卡案例:http://www.wglong.com/main/artical!details?id=11 现在直接贴代码了, js引用部分: <meta name="viewport" content="initial-sca

android中RecyclerView控件实现长按弹出PopupMenu菜单功能

之前写过一篇文章:android中实现简单的聊天功能 现在是在之前功能的基础上,添加一个长按聊天记录,删除对应聊天记录的功能 RecyclerView控件,没有对应的长按事件,我们需要自己手工添加,修改对应的适配器类,注意红色内容为添加内容 ChatAdapter.java: package com.example.chenrui.app1; import android.support.annotation.NonNull; import android.support.v7.widget.R

dede手机端首页点击文章内容、列表,却跳到pc端

手机访问到手机端首页,点击列表.内容.图片等都跳到pc端,是什么原因? 查看m模板里面的index.html文件生成的代码是绝对路径(数字随机)13.html 而不是view.php?aid=13 解决办法是什么? 首先在templets--------default---------找到index_m.html 打开index_m.html文件,查看调用代码 [field:arcurl /]这个调用代码是调用pc端的,只要换成view.php?aid=[field:id/]就可以正常跳转到手机

手机端radio控件 ios效果

一.CSS代码如下:    .switch {      position: relative;      margin: 20px auto;      height: 26px;      width: 120px;      background: rgba(0, 0, 0, 0.25);      border-radius: 3px;      box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 1px rgba(255, 255, 25

VB动态添加WebBrowser控件,并拦截弹出窗口(不用引用任何组件)

新建空白窗体,然后粘帖下面代码: 1 Option Explicit 2 Public WithEvents br As VBControlExtender 3 4 Private Sub br_ObjectEvent(Info As EventInfo) 5 If Info.Name = "NewWindow2" Then 6 'Dim fm As New Form1 7 'fm.Show 8 'Info.EventParameters(0) = br.object ‘根据需要可实现

JS与APP原生控件交互

"热更新"."热部署"相信对于混合式开发的童鞋一定不陌生,那么APP怎么避免每次升级都要在APP应用商店发布呢?这里就用到了混合式开发的概念,对于电商网站尤其显得重要,不可能每次发布一个活动,都要发布一个现版本,当然这样对于Android还算可以,但是对于Ios呢?苹果应用商店每次审核的时间基本都在1~2周,这对于一个促销活动来说审核时间实在太长.而混合式开发正好可以解决这个问题,基本的原理时,通过原生控件实现APP的主体结构,借助H5开发对应的页面,这样每次发布活

js多选日期控件

js多选日期控件 详情请见:http://www.lovewebgames.com/jsmodule/calendar.html 它的github地址:https://github.com/tianxiangbing/calendar calendar js日历控件 用法 1 <input type="text" id="calendar" value="2015-04-15"/> 2 <script src="../

js动态添加file控件

<html></head><script language="javascript" type="text/ecmascript">//======================//功能:在表单中input file控件//参数:parentID---要插入input file控件的父元素ID// inputID----input file控件的ID//======================function createI

MyEclipse添加JS插件(Spket控件)

一.安装Spket 网上更新方式 1.插件首页:http://www.spket.com        2.插件名称:Spket IDE        3.更新连接(Update Site):http://www.agpad.com/update 更新安装方法: 1.[Help]-[Software Updates]-[Find and Install...] 2.[Search for new features to install] -> [Next] 3.[New Remote Site.