Posts Tagged ‘JavaScript’

7 09 2009

Super fast build HTML string

bigCat Posted in JavaScript - 0 Comment

The holy grail!

var arr = ['item 1', 'item 2', 'item 3', ...];

var list = '

  • ' + arr.join('
  • ') + '

';

http://james.padolsey.com/javascript/fastest-way-to-build-an-html-string/

9 08 2009

用javascript获取屏幕高度和宽度等信息

bigCat Posted in JavaScript - 1 Comment

网页可见区域宽: document.documentElement.clientWidth
网页可见区域高: document.documentElement.clientHeight
网页可见区域宽: document.documentElement.offsetWidth (包括边线的宽)
网页可见区域高: document.documentElement.offsetHeight (包括边线的高)
网页正文全文宽: document.documentElement.scrollWidth
网页正文全文高: document.documentElement.scrollHeight
网页被卷去的高: document.documentElement.scrollTop
网页被卷去的左: document.documentElement.scrollLeft
网页正文部分上: window.screenTop
网页正文部分左: window.screenLeft
屏幕分辨率的高: window.screen.height
屏幕分辨率的宽: window.screen.width
屏幕可用工作区高度: window.screen.availHeight
屏幕可用工作区宽度: window.screen.availWidth

documentElement
28 04 2009

橱窗-逃出overflow

bigCat Posted in CSS, JavaScript - 1 Comment

/* 090424 add by bigCat showCaseHover */
var timeOutId; //鼠标移出定时器
jQuery(".showCaseProductBox ul").bind("mouseenter",
function() {
clearTimeout(timeOutId);
jQuery("#companyShowCase").find(".a").remove();
jQuery(this).find(".hint").clone().prependTo(jQuery("#companyShowCase")).addClass("a");
var offset = jQuery(this).offset();
jQuery("#companyShowCase").children(".a").attr("style", function() {
return 'display:block;left:' + (offset.left + 16) + 'px;top:' + (offset.top + 14) + 'px';
});
jQuery("#companyShowCase").find(".a")
.bind("mouseleave", function() {
jQuery(this).remove();
})
.bind("mouseenter", function() {
clearTimeout(timeOutId);
});
});
jQuery(".showCaseProductBox ul").bind("mouseleave",
function() {
timeOutId = setTimeout(function() {
jQuery("#companyShowCase").find(".a").remove();
}, 100);
}
);

Host: (miao) | Word: Press | Code: bigCat | Valid: HTML5