PDA

View Full Version : Size of window & style type


Kie UK
11-04-2003, 11:48 AM
I wonder if anyone could point me towards a script that would do the following?

I have a page that is just too big to fit on to a 800x600 browser if it has a 10 pixel border.

I use the following script to determine the size of margin:

<style type="text/css">
body {
margin: 10px;
padding: 0px;
}
</style>

Is there any way a script could detect the size of a browser and if 800x600 or smaller, change the style type to:

<style type="text/css">
body {
margin: 0px;
padding: 0px;
}
</style>

Many thanks

coothead
11-04-2003, 01:57 PM
Hi there Kie UK,

Try this<html>
<head>

<style type="text/css">
<!--
.first
{
margin: 10px;
padding: 0px;
background-color:#ff0000;
}
.second
{
margin: 0px;
padding: 0px;
background-color:#0000ff;
}
//-->
</style>

<script type="text/javascript">

function sniffer()
{
var screen_height = screen.height;
var screen_width = screen.width;
if (screen_height >= 768)
{
screen_width = 1024;
screen_height = 768;
change('changeme', 'first');
}
else
{
screen_width = 800;
screen_height = 600;
change('changeme', 'second');
}
}

function change(id, newClass)
{
identity=document.getElementById(id);
identity.className=newClass;
}
//-->
</script>

</head>

<body class="first" id="changeme"onload="sniffer();">

</body>
</html>
I have tested code in IE 6.0, Mozilla 1.4 and Netscape 7.1.

c:cool::cool:thead

Kie UK
11-05-2003, 04:19 AM
Thanks mate!!!

Kie UK
11-05-2003, 05:19 AM
Hmm that doesn't seem to have worked:

My page here (http://www.urbanforums.com/domino/winners/)

Any ideas what's going wrong?!

coothead
11-05-2003, 07:22 AM
Hi there Kie UK,

You have forgotten to change the body tag :rolleyes:
It should look like this....

<body class="first" id="changeme" onLoad="MM_preloadImage('../images/backbutton_f2.gif');sniffer();">

c:D:Dthead

Kie UK
11-05-2003, 07:24 AM
oops! sorry

thanks a lot