bootstrap实现弹出窗口

bootstrap使用modal-dialog实现弹对话框。

一个对话框包含3部分:

对话框头部 modal-header

对话框内容体 modal-body

对话框底部 modal-footer

如下html可以放入<body>标签的任何位置,我习惯紧随<body>标签之后。

html代码片段:

<div class="modal fade" id="loginModalId" tabindex="-1" role="dialog" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title" id="myModalLabel">登录提示:</h4>
					</div>
					<div class="modal-body">
						<div class="input-group">
							<span class="input-group-addon" id="basic-addon3">帐号:</span>
							<input type="text" class="input-sm" id="loginUser" aria-describedby="basic-addon3" placeholder="admin">
						</div>
						<div class="input-group">
							<span class="input-group-addon" id="basic-addon3">密码:</span>
							<input type="password" class="input-sm" id="loginPassword" aria-describedby="basic-addon3" placeholder="******">
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						<button type="button" class="btn btn-primary" id="loginModalYesId">登录</button>
					</div>
				</div>
			</div>
		</div>

默认div是隐藏的 aria-hidden="true"

显示效果:

增加一个触发弹出对话框的按钮。

<button type="button" class="btn btn-blue nav-external animated hiding" id="loginBntId" hidden="true">点击登录...</button>

增加js代码,当按钮loginBtnId按下时,显示对话框($(‘#loginModalId‘).modal(‘show‘);)。

$(document).ready(function() {
	document.getElementById("loginBntId").onclick = function() {
		$(‘#loginModalId‘).modal(‘show‘);
	}
	document.getElementById("loginModalYesId").onclick = function() {
		$(‘#loginModalId‘).modal(‘hide‘);
		alert("登录功能未实现!");
	}
});

为对话框上的 登录 按钮增加点击事件,事件发生后隐藏对话框($(‘#loginModalId‘).modal(‘hide‘);),并触发登录操作("登录功能未实现!")

参考:

http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html?from=androidqq

时间: 2024-08-24 22:28:05

bootstrap实现弹出窗口的相关文章

bootstrap 解决弹出窗口(modal) 常见问题

无法使用键盘esc关闭窗口方法: 首先在modal容器的div中增加属性tabindex="-1",其次设置键盘ESC属性keyboard为true: 方法1:使用js打开窗口时 $("#modal").modal({keyboard:true}) 方法2:使用H5属性在modal窗口的div中增加data-keyboard="true": 点击弹出框(modal)外空白处会关闭弹出窗口(modal): 使用backdrop属性,如果希望有背景则

jsp网页弹出窗口的多种办法

http://blog.csdn.net/huangfoxjava/article/details/2973033 登录|注册     huangfoxjava的专栏 目录视图 摘要视图 订阅 关于jsp网页弹出窗口[很多种方法......] 分类: JSP2008-09-24 14:22 5799人阅读 评论(0) 收藏 举报 jspjavascript框架html脚本浏览器 各种弹出页面的设计 [1.普通的弹出窗口] 其实代码非常简单: <SCRIPT LANGUAGE=javascript

软件测试---弹出窗口

视频地址(第五课时):https://pan.baidu.com/s/1gfLVC2n  alert 弹出窗口 Alert Should Be Present Get Alert Message  confirm 弹出窗口 Choose Cancel On Next Confirmation Choose Ok On Next Confirmation Confirm Action AutoIt Libary

JS中,根据div数值判断弹出窗口

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> div{ width: 50px; height: 50px; margin: 20px; float: left; border: 1px solid orange; } </style>

android弹出窗口的实现(PopupWindow)

最近看到新浪微博顶部栏的微博分组效果很炫,从网上查了一些资料明白原来是用PopupWindow实现的,今天自己也写了一个例子实现了这种效果,希望对大家有帮助. PopupWindow就是弹出窗口的意思,类似windows下面的开始按钮.PopupWindow可以实现浮层效果,而且可以自定义显示位置,出现和退出时的动画. 首先定义新浪微博的顶部栏,title_two_button.xml和main.xml [html] view plaincopyprint? <?xml version="

fancybox关闭弹出窗口parent.$.fancybox.close();

fancybox弹出窗口右上角会自带一个关闭窗口,并且点击遮罩层也会关闭fancybox 有时我们不需要这样进行关闭,隐藏关闭窗口,并且遮罩层不可点击 在弹出窗口页面加一链接进行关闭使用parent.$.fancybox.close();可进行对其关闭 以下为弹出页面的代码: function myclose(){ parent.$.fancybox.close(); } <a href="javascript:myclose();">关闭</a> 需要注意的一

asp .NET弹出窗口 汇总(精华,麒麟创想)

asp .NET弹出窗口 汇总(精华,麒麟创想) 注://关闭,父窗口弹出对话框,子窗口直接关闭 this.Response.Write("<script language=javascript>window.close();</script>"); //关闭,父窗口和子窗口都不弹出对话框,直接关闭 this.Response.Write("<script>");this.Response.Write("{top.ope

弹出窗口

1.新建模式对话框(浏览器窗口在最顶层): 1 function DotVideo2() { 2 var id = '@ViewBag.TopicsID'; 3 //模式对话框 4 window.showModelessDialog('/ConferenceFront/DocVideoPlay?TopicID=' + id + '', 'newwindow', 'dialogheight:480px;dialogwidth:300px;dialogtop:10px;dialogleft:880p

JS弹出窗口代码大全(详细整理)

1.弹启一个全屏窗口 复制代码代码如下: <html> <body http://www.jb51.net','脚本之家','fullscreen');">; <b>www.jb51.net</b> </body> </html> 2.弹启一个被F11化后的窗口 复制代码代码如下: <html> <body 'http://www.jb51.net','脚本之家','channelmode');"