I want to create a new layer including a login form (or other features), and I want to display it at center of the screen (depending on the screen's resolution and content).
This is the code :
function new_layer() {
$('#frameContainer, #showbox').show();
$('#showbox').load('includes/login.php');
$(document).ready(function(){
var hei = eval($(window).height()/2 - $('#showbox > *').outerHeight()/2);
var wid = eval($(window).width()/2 - $('#showbox > *').outerWidth()/2);
$('#showbox').css({
top: hei + "px",
left: wid + "px"
}).show();
});
// ..................
At the first time, it does not work, the content of the file login.php
is centered :( , but when I click outside to hide it, then click again, it works. When I refresh the page, the problem occurs again.
What is the problem and how can i fix it?