1
我給了if else語句一個刺,不知道我是否正確寫這個......嘗試獲取它,以便如果popupHeight維度大於windowHeight維度,那麼它會將它置於頂端視+ 10px的...Div定位
$("#data").load("/content/" + htmlName + ".html", null, function(){
//Set Variables
var container = $(".container");
var project = $(".project");
var popupWidth = container.find(".project img:first").width();
var popupHeight = container.find(".project img:first").height()+35;
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var x = ($(window).width()/2 - popupWidth/2) + $(window).scrollLeft();
var y = ($(window).height()/2 - popupHeight/2) + $(window).scrollTop();
//Set popup dimensions
container.css("width" , popupWidth);
container.css("height" , popupHeight);
//Set popup CSS
container.css({"position": "absolute", "left": x + "px", "z-index": "2" });
project.css({"width": (popupWidth), "height": (popupHeight) });
//Determine Position
if(popupHeight>windowHeight) {
container.css{("top": $(window).scrollTop(); + 10 + "px")
}else{
container.css({"top": y + "px"});
return;
}
});
是什麼問題? – stimms 2009-09-16 01:56:58
我認爲是代碼不工作... – RageZ 2009-09-16 01:58:48
如果和其他部分的代碼不工作,我得到一個語法錯誤... – antonanton 2009-09-16 02:06:24