同一页面上有多个弹出窗口 [英] multiple popups on same page
本文介绍了同一页面上有多个弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在设计一个页面,其中有几个链接。并且点击不同的弹出窗口必须弹出。但我只获得所有链接上的第一个弹出窗口。请帮助我
这是我的代码...
HTML ..
i am designing a page in which there are several links. and on clicking different popups has to pop. but i m getting only the 1st popup on all links. pls help me
here is my code...
HTML..
<a href="#login-box" popup-id="pop1" class="login-window">Next Maintenance Due</a>
<div id="login-box" class="login-popup">
<a href="#" class="close"><img src="image/close.jpg" width="20" height="20" class="btn_close" title="Close Window" alt="Close" /></a>
<form method="post" class="signin" action="#">
<fieldset class="textbox">
<label class="username">
<span>Next Maintenance Due:</span>
<input id="next_main" name="next_main" value="" type="text" autocomplete="on" readonly="readonly">
</label><br />
</fieldset>
</form>
</div>
<a href="#login-box" popup-id="pop2" class="login-window">Last Maintenance Carried Out</a>
<div id="Div1" class="login-popup">
<a href="#" class="close"><img src="image/close.jpg" width="20" height="20" class="btn_close" title="Close Window" alt="Close" /></a>
<form method="post" class="signin" action="#">
<fieldset class="textbox">
<label class="username">
<span>Last Maintenance Carried Out:</span>
<input id="Text2" name="last_main" value="" type="text" autocomplete="on" readonly="readonly">
</label><br />
</fieldset>
</form>
</div>
CSS ..
CSS..
#mask {
display: none;
background: #000;
position: fixed; left: 0; top: 0;
z-index: 10;
width: 100%; height: 100%;
opacity: 0.8;
z-index: 999;
}
.login-popup{
display:none;
background: #333;
padding: 10px;
border: 2px solid #ddd;
float: left;
font-size: 1.2em;
color:White;
position: fixed;
top: 50%; left: 50%;
z-index: 99999;
box-shadow: 0px 0px 20px #999;
-moz-box-shadow: 0px 0px 20px #999; /* Firefox */
-webkit-box-shadow: 0px 0px 20px #999; /* Safari, Chrome */
border-radius:3px 3px 3px 3px;
-moz-border-radius: 3px; /* Firefox */
-webkit-border-radius: 3px; /* Safari, Chrome */
}
img.btn_close {
float: right;
margin: -28px -28px 0 0;
}
fieldset {
border:none;
}
form.signin .textbox label {
display:block;
padding-bottom:7px;
}
form.signin .textbox span {
display:block;
}
form.signin p, form.signin span {
color:#999;
font-size:11px;
line-height:18px;
}
form.signin .textbox input {
background:#666666;
border-bottom:1px solid #333;
border-left:1px solid #000;
border-right:1px solid #333;
border-top:1px solid #000;
color:#fff;
border-radius: 3px 3px 3px 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
font:13px Arial, Helvetica, sans-serif;
padding:6px 6px 4px;
width:200px;
}
form.signin input:-moz-placeholder { color:#bbb; text-shadow:0 0 2px #000; }
form.signin input::-webkit-input-placeholder { color:#bbb; text-shadow:0 0 2px #000; }
.button {
background: -moz-linear-gradient(center top, #f3f3f3, #dddddd);
background: -webkit-gradient(linear, left top, left bottom, from(#f3f3f3), to(#dddddd));
background: -o-linear-gradient(top, #f3f3f3, #dddddd);
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f3f3f3', EndColorStr='#dddddd');
border-color:#000;
border-width:1px;
border-radius:4px 4px 4px 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
color:#333;
cursor:pointer;
display:inline-block;
padding:6px 6px 4px;
margin-top:10px;
font:12px;
width:214px;
}
.button:hover { background:#ddd; }
Jscript
Jscript
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.login-window').click(function () {
// Getting the variable's value from a link
var loginBox = $(this).attr('href');
//Fade in the Popup and add close button
$(loginBox).fadeIn(300);
//Set the center alignment padding + border
var popMargTop = ($(loginBox).height() + 24) / 2;
var popMargLeft = ($(loginBox).width() + 24) / 2;
$(loginBox).css({
'margin-top': -popMargTop,
'margin-left': -popMargLeft
});
// Add the mask to body
$('body').append('<div id="mask"></div>');
$('#mask').fadeIn(300);
return false;
});
// When clicking on the button close or the mask layer the popup closed
$('.close, #mask').live('click', function () {
$('#mask , .login-popup').fadeOut(300, function () {
$('#mask').remove();
});
return false;
});
});
推荐答案
( document )。ready ( function (){
(document).ready(function () {
(' .login-window')。点击( function (){
// 从链接获取变量值
var loginBox =
('.login-window').click(function () { // Getting the variable's value from a link var loginBox =
( this )。attr(' < span class =code-string> href');
// 淡入弹出窗口并添加关闭按钮
(this).attr('href'); //Fade in the Popup and add close button
这篇关于同一页面上有多个弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文