Web Hosting Talk







View Full Version : dhtml question regarding screen.width


GregShasta
07-16-2001, 01:44 AM
i cant figure out this script that i want to use. need a little help here im trying to use a script that will shift the body of my page 100px left if visitors have a screen width greater than 800. now the whole body is enclosed in one div and ive tried this script:

if(screen.width>800)
{document.all.dissapear.style.pixelLeft=100;}

now its in the head section enclosed between <script> tags. the odd thing is that if i use a link to it and make it a function it will work perfectly minus the if statement.

oh and 'dissapear' is the id of my body div.

thx,
Greg

oh also get this if i use this function call in the body:
<div onClick="checker()"><a href="#">click me</a></div>


to this function in the head:
function checker()
{document.all.dissapear.style.pixelLeft=100;}

it works fine catch 22 is that i want it to change 'dynamically' based on the visitors screen size.

onLoad wont call it which leads me to believe its a problem with my if statement.

XTStrike
07-19-2001, 04:11 AM
moved to tech forum as this is more technical based.