View Single Post
Sponsorlu Bağlantılar
Zoque.Forum
Advertisement
Old 13.05.2001   #4 (permalink)
SiLueT
 
Üyelik Tarihi: 05.06.2000
Mesaj: 95
Centered Layer

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>

<title>ortalanmis layer</title>


<script language="JavaScript1.2">

function Is() {
var agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla') != -1) &&
(agent.indexOf('spoofer') == -1) &&
(agent.indexOf('compatible') == -1) &&
(agent.indexOf('opera') == -1) &&
(agent.indexOf('webtv') == -1));
this.ns4 = (this.ns && (this.major == 4));
this.ns6 = (this.ns && (this.major >= 5));
this.ie = (agent.indexOf("msie") != -1);
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major >= 4));
this.ie5 = (this.ie && (this.major == 4) &&
(agent.indexOf("msie 5.0") != -1));
this.ieX = (this.ie && !this.ie3 && !this.ie4);
}

var is = new Is();


function layerObject(id,left,top) {

if (is.ie5||is.ns6){
this.obj = document.getElementById(id).style;
this.obj.left = left;
this.obj.top = top;
return this.obj;
} else if(is.ie4) {
this.obj = document.all[id].style;
this.obj.left = left;
this.obj.top = top;
return this.obj;
} else if(is.ns4) {
this.obj = document.layers[id] ;
this.obj.left = left;
this.obj.top = top;
return this.obj;
}
}


function init() {
if(is.ns4 ||is.ns6) {
available_width=innerWidth;
available_height=innerHeight;
layerSetup();
} else if(is.ie4 || is.ie5) {
available_width=document.body.clientWidth;
available_height=document.body.clientHeight;
layerSetup();
}
}

function resizePage() {
if(is.ns4 ||is.ns6||is.ie4||is.ie5) {
history.go(0);
}
}


function layerSetup() {
centerLyr = new layerObject('centerLayer', available_width/2-350,available_height/2-200);
}

</script>

</head>

<body onLoad="init()" onResize="resizePage()" leftmargin=0 topmargin=0>

<div id="centerLayer" style="position: absolute; width:700px; height:400px; background-color:#aaaaff; layer-backgroundcolor:#aaaaff;">
<table width="700" height="400" border="1">
<tr>
<td align=center><font size=3 face=arial>Bu, horizontal ve vertical olarak ortalanmis bir layer'dir </td>
</tr>
</table>
</div>

</body>
</HTML>


* * * * * * * * * * * * * * * * * * * * *

gecenlerde soruna cevap verecek firsatim olmamisti.
bugun can sikintisindan oturup birseyler yapayim dedim.

bu kod sanirim senin ihtiyacini karsilayacaktir.
JavaScript ile browser'in kullanilabilir alanini hesapliyor once.. sonra layer'in genisligiyle bir islem yapilip layerin surekli sayfanin ortasinda kalmasi saglaniyor. body'in onResize ozelliginden de yararlanilarak browser resize edilse bile bu hareket gecerli kiliniyor.

kod netscape ve internet Explorer 4+'ta calisacak durumdadir.

iyi calismalar diliyorum.

ha unutmadan;
hazirladigin layerin ortalanmasi icin;
function layerSetup() {
centerLyr = new layerObject('centerLayer', available_width/2-350,available_height/2-200);
}

bu fonksiyonda bulunan;
available_width/2-350
available_height/2-200
alanlarında
350 ve 200 degerleri, hazirladigin layerin boyutlarinin yarisi kadar olmali..
yani 800x300 boyutunda bir layer hazirlamissan,
available_width/2-400
available_height/2-150
yazmalisin.

neyse cok uzattim..
__________________
Sad had been here!..
SiLueT şu an çevrimdışı   Mesajdan alıntı yaparak yeni bir cevap ekleyin