Jump to content
Fórum Script Brasil
  • 0

Fechar Janela ao clicar em outro link do menu


Novato1989

Question

Galera, estou apanhando aqui...

estou com este código a baixo e que abre tipo uma janela, mas quando eu clico em outro link do menu, outra janela abre por cima e não fecha a anterior, eu gostaria que fechasse a anterior ou que quando clicasse em fechar, não fechasse todas as janelas, só a atual. Me ajudem ai por favor!

// JavaScript Document
$(document).ready(function() {
$('a[name=modal]').click(function(e) {
e.preventDefault();
var id = $(this).attr('href');
var maskHeight = $(document).height();
var maskWidth = $(window).width();
$('#mask').css({'width':maskWidth,'height':maskHeight});
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
$(id).fadeIn(2000);
});
$('.window').click(function (ev) {
ev.preventDefault();
$('#mask').hide();
$('.window').hide();
});
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
});
HTML
<li class='active has-sub'><a href='#'><span>Clientes</span></a>
<ul>
<li><a href="#dialog1" name="modal"><span>Cadastrar</span></a></li>
<li><a href="#dialog2" name="modal"><span>Vizualizar</span></a></li>
</ul>
</li>
<div id="principal" name="principal">
<div id="boxes">
<div id="dialog1" class="window">
<?php include "cliente_cadastro.php"; ?>
</div>
<div id="dialog2" class="window">
<?php include "teste.php";?>
</div>
</div>
</div>
CSS
a {
color:#333;
text-decoration:none;
}
a:hover {
color:#ccc;
text-decoration:none;
}
#mask {
position:absolute;
left:0;
top:0;
z-index:9000;
background-color: #000000;
display:none;
}
#boxes .window {
position:absolute;
left:0;
top:0;
width: auto;
height: auto;
display:none;
z-index:9999;
padding:20px;
}
#boxes #dialog {
width: auto;
height: auto;
padding:10px;
background-color:#ffffff;
}
.close{
text-align: right;
margin-right: 10px;
border: 0;
}

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...