日期:2014-05-16  浏览次数:20376 次

docment.write一个层,如何显示
代码如下:

document.write('<div id="djcamain" style="display:none;position:fixed;height:268px;width:210px;background:#FF0000;border:2px solid #cecece;z-index:2;padding:12px;font-size:13px;"><table><tr><td>年:<input id="txYear" width=50px size=8 />月:<input id="txMonth" width=30px value=01 size=6 /></td></tr></table></div>');

function jcaShow(obj){
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#djcamain").height();
var popupWidth = $("#djcamain").width();


$("#djcamain").css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2,
"left": windowWidth/2-popupWidth/2
}).fadeIn("slow");
}



为什么显示不出来, 大侠指点一下。谢谢。

------解决方案--------------------
display:none;  隐藏了 
------解决方案--------------------
没执行啊。
jcaShow();

document.write('<div id="djcamain" style="display:none;position:fixed;height:268px;width:210px;background:#FF0000;border:2px solid #cecece;z-index:2;padding:12px;font-size:13px;"><table><tr><td>年:<input id="txYear" width=50px size=8 />月:<input id="txMonth" width=30px value=01 size=6 /></td></tr></table></div>');

function jcaShow(obj){
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#djcamain").height();
var popupWidth = $("#djcamain").width();


$("#djcamain").css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2,
"left": windowWidth/2-popupWidth/2
}).fadeIn("slow");
}
jcaShow();

------解决方案--------------------
先直接document.write一个字符串试试,没看到的话那就debug看有没执行到啊