| | #1 |
| Bhadra Join Date: 2012
Posts: 47
Thanks: 18
Thanked 0 Times in 0 Posts
|
Hey warriors, I have a login system to log users in. For this, I have built the login in a box with display:none in css. After clicking the log in button, the body's opacity is changed from 1 to 0.5 by jquery css() method. The login box appears by using the same css() method. But the problem is that the mouse still responses to the links in the body. So, I want that the links in my website cannot be clicked till the box is closed. Please tell me how to do it? Thanks in advance. |
| | |
| |
| | #2 |
| Web Developer War Room Member Join Date: 2012 Location: Vancouver, BC
Posts: 593
Thanks: 149
Thanked 162 Times in 133 Posts
|
Dont change the opacity of the body, creat a new div inside the body to cover the content. Code: //css
#loader {
width:100%;
position:absolute;
display:none;
background:#333;
opacity:0.5;
}
//jQuery
$('#modalbox_button').click(function() {
//fire your login modal here
var bodyheight = $('body').height();
$('#loader').css('height', bodyheight);
$('#loader').css('display', 'block');
});
//HTML
<body>
<div id="loader"></div>
// rest of content
</body> |
| |
| |
| The Following User Says Thank You to Andrew H For This Useful Post: |
| | #3 |
| Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
|
If all you want to do is make the links in the main content area temporarily un-clickable, then you can simply do this... Code: $('.bodyLinks').attr('onClick', 'return false'); Code: $('.bodyLinks').attr('onClick', 'return true'); |
| | |
| |
| The Following User Says Thank You to Brandon Tanner For This Useful Post: |
| | #4 |
| VIP Warrior War Room Member Join Date: 2007 Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
|
If you want to make the rest of your page elements unclickable, you'll need to take Andrew's suggestion a little bit further. You'll want to make sure your overlay truly overlays the rest of the page content using z-index (notice 'position: relative' on the dialog box - browsers ignore z-index unless the container has a position other than 'static'). Also, if you don't want to clutter up your page HTML, you can use jQuery to add the overlay container... Code: //css
#loader {
width:100%;
position:absolute;
display:none;
background:#333;
opacity:0.5;
z-index: 10001;
}
#dialog-box {
position: relative;
z-index: 10002;
}
//jQuery
$('body').append('<div id="loader"></div>');
$('#modalbox_button').click(function() {
//fire your login modal here
var bodyheight = $('body').height();
$('#loader').css('height', bodyheight);
$('#loader').css('display', 'block');
}); |
| |
| The Following User Says Thank You to SteveJohnson For This Useful Post: |
|
| Bookmarks |
| Tags |
| jquery, problem |
| |