Marlboro
01-19-2001, 04:30 PM
Ok - the code below is my first attempt to "liquidize" a page for IE4, IE5, NS6 and NS4. Liquidizing means that objects on the page will automatically relocate based on screen size (event = onresize).
The code below works on IE4, IE5, IE5.5 and NS6. I would love it if someone could modifiy it so that it also works on NS4 (4.5 or higher preferably). Also I am experiencing an issue the ns6 is not properly locating the DIVs on the initial page load, but will upon resize - ideas? fixes? (like it is not able to calculate the height of DIVs)
For the really adventurous - if you want to streamline my code by all means do (interation is wondeful!), but please re-post it here so all can benefit, noting your enhancements.
Comments wanted - NS4 suport REALLY appreciated!
Mark
ps: the code does contain ASP code, so you will need to load this onto a server (the ASP is UA detection and var substitution)
If you do use this in some production code on your site, please be sure to contribute the source to me in your code. tia
===begin page resize code======
====orginal author: mark wray 1/2001=========
<%
if instr(request.servervariables("http_user_agent"),"MSIE 5") then 'ok
varHgt2 = "xHgt2 = document.getElementById('sec1').clientHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"Netscape6") then 'ok
varHgt2 = "xHgt2 = document.getElementById('sec1').offsetHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"MSIE 4") then 'ok
varHgt2 = "xHgt2 = document.all.sec1.scrollHeight +20;"
elseif instr(request.servervariables("http_user_agent"),"Mozilla/4") then
varHgt2 = "xHgt2 = document.layers.sec1.y +20;"
end if
if instr(request.servervariables("http_user_agent"),"MSIE 5") then
varHgt3 = "xHgt3 = document.getElementById('sec1').clientHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"Netscape6") then
varHgt3 = "xHgt3 = document.getElementById('sec1').offsetHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"MSIE 4") then
varHgt3 = "xHgt3 = document.all.sec1.scrollHeight +20;"
elseif instr(request.servervariables("http_user_agent"),"Mozilla/4") then
varHgt3 = "xHgt3 = document.layers.sec1.y +20;"
end if
if instr(request.servervariables("http_user_agent"),"MSIE 5") then
varHgt4 = "xHgt4 = document.getElementById('sec1').clientHeight + document.getElementById('sec2').clientHeight + 40 ;"
elseif instr(request.servervariables("http_user_agent"),"Netscape6") then
varHgt4 = "xHgt4 = document.getElementById('sec1').offsetHeight + 20 + document.getElementById('sec2').offsetHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"MSIE 4") then
varHgt4 = "xHgt4 = document.all.sec1.scrollHeight + document.all.sec2.scrollHeight + 40;"
elseif instr(request.servervariables("http_user_agent"),"Mozilla/4") then
varHgt4 = "xHgt4 = document.layers.sec1.y + document.layers.sec1.y + 40;"
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ULTRAPRISE.COM</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=iso-8859-1">
<META HTTP-EQUIV="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT">
<LINK href="../../ultrastyle1.css" rel="stylesheet" type="text/css">
<style>
#sec1 {position: absolute; top:0px; left: 0px; background-color:white; border-style:solid; border-width:2px; border-color:black;}
#sec2 {position: absolute; top:0px; left: 0px; background-color:MistyRose; border-style:solid; border-width:2px; border-color:black;}
#sec3 {position: absolute; top:0px; left: 0px; background-color:WhiteSmoke; border-style:solid; border-width:2px; border-color:RoyalBlue;}
#sec4 {position: absolute; top:0px; left: 0px; background-color:LightGrey; border-style:solid; border-width:2px; border-color:black;}
</style>
<script>
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ng5 =(document.getElementById)? true:false
var posL
var posT
var layW
//liquidize mode -
function setPos(id){
getSize();
posL = winW - (winW -10)
posT = winH - (winH -10)
layW = winW-40
//alert(posT);
if (document.getElementById) {//ie5x-ns6
document.getElementById(id).style.left = posL;
document.getElementById(id).style.top = posT;
document.getElementById(id).style.width = layW;}
if (document.all){//ie4x
document.all(id).style.left = posL;
document.all(id).style.top = posT;
document.all(id).style.width = layW;}
if (document.layers){//ns4x
document.layers[id].left = posL;
document.layers[id].top = posT;
document.layers[id].width = layW;}
}
var xHgt2
var posL2
var posT2
var layW2
function setPos2(id2){
<%=varHgt2%>
posL2 = winW - (winW -10);
posT2 = xHgt2;
layW2 = (winW/2)-60;
//alert(document.all.sec1.style.scrollHeight)
//alert(xHgt2);
if (document.getElementById) {//ie5x-ns6
document.getElementById(id2).style.left = posL2;
document.getElementById(id2).style.top = posT2;
document.getElementById(id2).style.width = layW2;}
if (document.all){//ie4x
document.all(id2).style.left = posL2;
document.all(id2).style.top = posT2;
document.all(id2).style.width = layW2;}
if (document.layers){//ns4x
document.layers[id2].left = posL2;
document.layers[id2].top = posT2;
document.layers[id2].width = layW2;}
}
var xHgt3
var posL3 //left co-ord
var posT3 //top co-ord
var layW3 //width dimension
function setPos3(id){
<%=varHgt3%>
posL3 = layW2 +15
posT3 = xHgt3;
layW3 = (winW/2)-60;
//alert(xHgt3);
if (document.getElementById) {//ie5x-ns6
document.getElementById(id).style.left = posL3;
document.getElementById(id).style.top = posT3;
document.getElementById(id).style.width = layW3;}
if (document.all){//ie4x
document.all(id).style.left = posL3;
document.all(id).style.top = posT3;
document.all(id).style.width = layW3;}
if (document.layers){//ns4x
document.layers[id].left = posL3;
document.layers[id].top = posT3;
document.layers[id].width = layW3;}
}
var xHgt4
var posL4 //left co-ord
var posT4 //top co-ord
var layW4 //width dimension
function setPos4(id){
<%=varHgt4%> //=xHgt4
posL4 = winW - (winW -10);
posT4 = xHgt4;
layW4 = (winW/2)-60;
//alert(xHgt3);
//alert(xHgt4);
if (document.getElementById) {//ie5x-ns6
document.getElementById(id).style.left = posL4;
document.getElementById(id).style.top = posT4;
document.getElementById(id).style.width = layW4;}
if (document.all){//ie4x
document.all(id).style.left = posL4;
document.all(id).style.top = posT4;
document.all(id).style.width = layW4;}
if (document.layers){//ns4x
document.layers[id].left = posL4;
document.layers[id].top = posT4;
document.layers[id].width = layW4;}
}
//end liquidization
//resize functions
function doRe(){
setPos('sec1');
setPos2('sec2');
setPos3('sec3');
setPos4('sec4');}
</script>
</head>
<body bgcolor="#ffffff" onLoad="doRe()" onResize="doRe()">
<script>
//screen size detection
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ng5 =(document.getElementById)? true:false
var winH
var winW
function getSize(){
if (ns4) {
winW = window.innerWidth;
winH = window.innerHeight;
if (window.innerWidth < 530) {winW = 530;}
}
else if (ie4) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
if (document.body.offsetWidth < 530) {winW = 530;}
}
else if (ng5) {
winW = self.innerWidth;
winH = self.innerHeight;
if (self.innerWidth < 530) {winW = 530;}
}
}
//===end screen size detect mode
</script>
<div id="sec1">
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr><td class="pagetitle" nowrap>welcome User </td><td class="pagetext" align="left">This is sample demo that shows the potential power of using a liquidized layout off of a grid control schema. This is sample demo that shows the potential power of using a liquidized layout off of a grid control schema. This is sample demo that shows the potential power of using a liquidized layout off of a grid control schema. This is sample demo that shows the potential power of using a liquidized layout off of a grid control schema. <b>sec1</b></td></tr>
</table>
</div>
<div id="sec2">
<table border="0" cellpadding="2" cellspacing="0"><tr><td>
This is some body content to just take up space and see what happens if this were an actual content section. Do not be alarmed this is only a test. <b>sec2</b>
<%=request.servervariables("http_user_agent") %>
</td></tr></table>
</div>
<div id="sec3">
<table border="0" cellpadding="2" cellspacing="0"><tr><td>
This page uses the technique of determining a DIV height to move other DIVs down upon document resize (if content exists above the pert layers). This method does not work in NS4.x due to being unable to ascertain the height of DIVs. The file xxxxxxx will contain a newer method that monitors the screen width and then adjusts the vertical positioning of the DIVs accordingly <b>sec3</b>
<%=request.servervariables("http_user_agent") %>
</td></tr></table>
</div>
<div id="sec4">
<table border="0" cellpadding="2" cellspacing="0"><tr><td>
This is some body content to just take up space and see what happens if this were an actual content section. Do not be alarmed this is only a test. <b>sec4</b>
<%=request.servervariables("http_user_agent") %>
<a href="#" onClick="doRe()">re-flow</a>
</td></tr></table>
</div>
</body>
</html>
The code below works on IE4, IE5, IE5.5 and NS6. I would love it if someone could modifiy it so that it also works on NS4 (4.5 or higher preferably). Also I am experiencing an issue the ns6 is not properly locating the DIVs on the initial page load, but will upon resize - ideas? fixes? (like it is not able to calculate the height of DIVs)
For the really adventurous - if you want to streamline my code by all means do (interation is wondeful!), but please re-post it here so all can benefit, noting your enhancements.
Comments wanted - NS4 suport REALLY appreciated!
Mark
ps: the code does contain ASP code, so you will need to load this onto a server (the ASP is UA detection and var substitution)
If you do use this in some production code on your site, please be sure to contribute the source to me in your code. tia
===begin page resize code======
====orginal author: mark wray 1/2001=========
<%
if instr(request.servervariables("http_user_agent"),"MSIE 5") then 'ok
varHgt2 = "xHgt2 = document.getElementById('sec1').clientHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"Netscape6") then 'ok
varHgt2 = "xHgt2 = document.getElementById('sec1').offsetHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"MSIE 4") then 'ok
varHgt2 = "xHgt2 = document.all.sec1.scrollHeight +20;"
elseif instr(request.servervariables("http_user_agent"),"Mozilla/4") then
varHgt2 = "xHgt2 = document.layers.sec1.y +20;"
end if
if instr(request.servervariables("http_user_agent"),"MSIE 5") then
varHgt3 = "xHgt3 = document.getElementById('sec1').clientHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"Netscape6") then
varHgt3 = "xHgt3 = document.getElementById('sec1').offsetHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"MSIE 4") then
varHgt3 = "xHgt3 = document.all.sec1.scrollHeight +20;"
elseif instr(request.servervariables("http_user_agent"),"Mozilla/4") then
varHgt3 = "xHgt3 = document.layers.sec1.y +20;"
end if
if instr(request.servervariables("http_user_agent"),"MSIE 5") then
varHgt4 = "xHgt4 = document.getElementById('sec1').clientHeight + document.getElementById('sec2').clientHeight + 40 ;"
elseif instr(request.servervariables("http_user_agent"),"Netscape6") then
varHgt4 = "xHgt4 = document.getElementById('sec1').offsetHeight + 20 + document.getElementById('sec2').offsetHeight + 20;"
elseif instr(request.servervariables("http_user_agent"),"MSIE 4") then
varHgt4 = "xHgt4 = document.all.sec1.scrollHeight + document.all.sec2.scrollHeight + 40;"
elseif instr(request.servervariables("http_user_agent"),"Mozilla/4") then
varHgt4 = "xHgt4 = document.layers.sec1.y + document.layers.sec1.y + 40;"
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ULTRAPRISE.COM</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=iso-8859-1">
<META HTTP-EQUIV="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT">
<LINK href="../../ultrastyle1.css" rel="stylesheet" type="text/css">
<style>
#sec1 {position: absolute; top:0px; left: 0px; background-color:white; border-style:solid; border-width:2px; border-color:black;}
#sec2 {position: absolute; top:0px; left: 0px; background-color:MistyRose; border-style:solid; border-width:2px; border-color:black;}
#sec3 {position: absolute; top:0px; left: 0px; background-color:WhiteSmoke; border-style:solid; border-width:2px; border-color:RoyalBlue;}
#sec4 {position: absolute; top:0px; left: 0px; background-color:LightGrey; border-style:solid; border-width:2px; border-color:black;}
</style>
<script>
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ng5 =(document.getElementById)? true:false
var posL
var posT
var layW
//liquidize mode -
function setPos(id){
getSize();
posL = winW - (winW -10)
posT = winH - (winH -10)
layW = winW-40
//alert(posT);
if (document.getElementById) {//ie5x-ns6
document.getElementById(id).style.left = posL;
document.getElementById(id).style.top = posT;
document.getElementById(id).style.width = layW;}
if (document.all){//ie4x
document.all(id).style.left = posL;
document.all(id).style.top = posT;
document.all(id).style.width = layW;}
if (document.layers){//ns4x
document.layers[id].left = posL;
document.layers[id].top = posT;
document.layers[id].width = layW;}
}
var xHgt2
var posL2
var posT2
var layW2
function setPos2(id2){
<%=varHgt2%>
posL2 = winW - (winW -10);
posT2 = xHgt2;
layW2 = (winW/2)-60;
//alert(document.all.sec1.style.scrollHeight)
//alert(xHgt2);
if (document.getElementById) {//ie5x-ns6
document.getElementById(id2).style.left = posL2;
document.getElementById(id2).style.top = posT2;
document.getElementById(id2).style.width = layW2;}
if (document.all){//ie4x
document.all(id2).style.left = posL2;
document.all(id2).style.top = posT2;
document.all(id2).style.width = layW2;}
if (document.layers){//ns4x
document.layers[id2].left = posL2;
document.layers[id2].top = posT2;
document.layers[id2].width = layW2;}
}
var xHgt3
var posL3 //left co-ord
var posT3 //top co-ord
var layW3 //width dimension
function setPos3(id){
<%=varHgt3%>
posL3 = layW2 +15
posT3 = xHgt3;
layW3 = (winW/2)-60;
//alert(xHgt3);
if (document.getElementById) {//ie5x-ns6
document.getElementById(id).style.left = posL3;
document.getElementById(id).style.top = posT3;
document.getElementById(id).style.width = layW3;}
if (document.all){//ie4x
document.all(id).style.left = posL3;
document.all(id).style.top = posT3;
document.all(id).style.width = layW3;}
if (document.layers){//ns4x
document.layers[id].left = posL3;
document.layers[id].top = posT3;
document.layers[id].width = layW3;}
}
var xHgt4
var posL4 //left co-ord
var posT4 //top co-ord
var layW4 //width dimension
function setPos4(id){
<%=varHgt4%> //=xHgt4
posL4 = winW - (winW -10);
posT4 = xHgt4;
layW4 = (winW/2)-60;
//alert(xHgt3);
//alert(xHgt4);
if (document.getElementById) {//ie5x-ns6
document.getElementById(id).style.left = posL4;
document.getElementById(id).style.top = posT4;
document.getElementById(id).style.width = layW4;}
if (document.all){//ie4x
document.all(id).style.left = posL4;
document.all(id).style.top = posT4;
document.all(id).style.width = layW4;}
if (document.layers){//ns4x
document.layers[id].left = posL4;
document.layers[id].top = posT4;
document.layers[id].width = layW4;}
}
//end liquidization
//resize functions
function doRe(){
setPos('sec1');
setPos2('sec2');
setPos3('sec3');
setPos4('sec4');}
</script>
</head>
<body bgcolor="#ffffff" onLoad="doRe()" onResize="doRe()">
<script>
//screen size detection
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ng5 =(document.getElementById)? true:false
var winH
var winW
function getSize(){
if (ns4) {
winW = window.innerWidth;
winH = window.innerHeight;
if (window.innerWidth < 530) {winW = 530;}
}
else if (ie4) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
if (document.body.offsetWidth < 530) {winW = 530;}
}
else if (ng5) {
winW = self.innerWidth;
winH = self.innerHeight;
if (self.innerWidth < 530) {winW = 530;}
}
}
//===end screen size detect mode
</script>
<div id="sec1">
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr><td class="pagetitle" nowrap>welcome User </td><td class="pagetext" align="left">This is sample demo that shows the potential power of using a liquidized layout off of a grid control schema. This is sample demo that shows the potential power of using a liquidized layout off of a grid control schema. This is sample demo that shows the potential power of using a liquidized layout off of a grid control schema. This is sample demo that shows the potential power of using a liquidized layout off of a grid control schema. <b>sec1</b></td></tr>
</table>
</div>
<div id="sec2">
<table border="0" cellpadding="2" cellspacing="0"><tr><td>
This is some body content to just take up space and see what happens if this were an actual content section. Do not be alarmed this is only a test. <b>sec2</b>
<%=request.servervariables("http_user_agent") %>
</td></tr></table>
</div>
<div id="sec3">
<table border="0" cellpadding="2" cellspacing="0"><tr><td>
This page uses the technique of determining a DIV height to move other DIVs down upon document resize (if content exists above the pert layers). This method does not work in NS4.x due to being unable to ascertain the height of DIVs. The file xxxxxxx will contain a newer method that monitors the screen width and then adjusts the vertical positioning of the DIVs accordingly <b>sec3</b>
<%=request.servervariables("http_user_agent") %>
</td></tr></table>
</div>
<div id="sec4">
<table border="0" cellpadding="2" cellspacing="0"><tr><td>
This is some body content to just take up space and see what happens if this were an actual content section. Do not be alarmed this is only a test. <b>sec4</b>
<%=request.servervariables("http_user_agent") %>
<a href="#" onClick="doRe()">re-flow</a>
</td></tr></table>
</div>
</body>
</html>