-
Notifications
You must be signed in to change notification settings - Fork 1
/
footerFixed.js
74 lines (66 loc) · 1.95 KB
/
footerFixed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*--------------------------------------------------------------------------*
*
* footerFixed.js
*
* MIT-style license.
*
* 2007 Kazuma Nishihata [to-R]
* http://blog.webcreativepark.net
*
*--------------------------------------------------------------------------*/
new function(){
var footerId = "footer";
//���C��
function footerFixed(){
//�h�L�������g�̍���
var dh = document.getElementsByTagName("body")[0].clientHeight;
//�t�b�^�[��top����̈ʒu
document.getElementById(footerId).style.top = "0px";
var ft = document.getElementById(footerId).offsetTop;
//�t�b�^�[�̍���
var fh = document.getElementById(footerId).offsetHeight;
//�E�B���h�E�̍���
if (window.innerHeight){
var wh = window.innerHeight;
}else if(document.documentElement && document.documentElement.clientHeight != 0){
var wh = document.documentElement.clientHeight;
}
if(ft+fh<wh){
document.getElementById(footerId).style.position = "relative";
document.getElementById(footerId).style.top = (wh-fh-ft-1)+"px";
}
}
//�����T�C�Y
function checkFontSize(func){
//����v�f�̒lj�
var e = document.createElement("div");
var s = document.createTextNode("S");
e.appendChild(s);
e.style.visibility="hidden"
e.style.position="absolute"
e.style.top="0"
document.body.appendChild(e);
var defHeight = e.offsetHeight;
//�����
function checkBoxSize(){
if(defHeight != e.offsetHeight){
func();
defHeight= e.offsetHeight;
}
}
setInterval(checkBoxSize,1000)
}
//�C�x���g���X�i�[
function addEvent(elm,listener,fn){
try{
elm.addEventListener(listener,fn,false);
}catch(e){
elm.attachEvent("on"+listener,fn);
}
}
addEvent(window,"load",footerFixed);
addEvent(window,"load",function(){
checkFontSize(footerFixed);
});
addEvent(window,"resize",footerFixed);
}