I am trying to set the body overflow property to hidden when the "popup" class is used and called by JavaScript. However, my CSS implementation does not seem to be working.
#CSS
.popup {
display: table;
height: 100% !important;
table-layout: fixed;
width: 100%;
position: fixed;
top: 0px;
bottom: 0px;
z-index: 400;
}
.popup body {
overflow: hidden!important;
}
My scenario involves clicking on Facebook photos, where they appear fullscreen and lock scrolling. Any help on this matter would be greatly appreciated.
This is how I call it:
<a href="#" onclick="getphoto(int)">Click to view larger</a>
JavaScript
function getphoto(inputString) {
$('body').css('overflow', 'hidden');
if(inputString.length == 0||false) {
$('#suggestions3').fadeOut(); // Hide the suggestions box
}else{
//alert(inputString);
$.post("p/photo.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
$('#suggestions3').fadeIn(); // Show the suggestions box
$('#suggestions3').html(data); // Fill the suggestions box
});
}
}
The inputString represents the photo ID. In photo.php, it returns HTML content
<div class="popup">...my content...</div>