PDA

View Full Version : Trying to show a layer (OnLoad) per resolution


gelcode
07-18-2002, 11:23 PM
Here's the problem... I am working on a page which is designed for a
1024x768 res, however looks okay on a 800x600. I want to set a OnLoad Show Layer command if browser width is less than 835 pix.

I am a newb at coding but have figured some stuff out. I grabbed this code off of two DW behaviors... how can I combine the two and make it work?

Resolution script...

//-->
//tmtC_resolutionRedirect
if (window.screen){
var w = screen.width;
tmt_url_800 = "resprob.htm";
if(w<835){
self.location.replace(tmt_url_800);
}
}//tmtC_resolutionRedirectEnd</script>


Show Layer script...

function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null)
{ v=args[i+2];
if (obj.style) { obj=obj.style;
v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
//-->
</script>

TIA

gelcode
07-18-2002, 11:23 PM
Damn Smileys

gelcode
07-19-2002, 03:07 AM
I think I have got an idea of how to accomplish this, but I think it needssome tweeking...

If someone could help me out I would be indebted

In the head I defined the following function...

function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null)
{ v=args[i+2];
if (obj.style) { obj=obj.style;
v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
//-->

I then created this script...

//-->
//tmtC_resolutionLayers
if (window.screen){
var w = screen.width;
tmt_lay_800 = ('ResNotice','','show');

if (w<=850){
MM_showHideLayers(tmt_lay_800);
}
}//tmtC_resolutionLayersEnd


using this as a template...

//-->
//tmtC_resolutionRedirect
if (window.screen){
var w = screen.width;
tmt_url_640 = "resprob.htm";

if(w<740){
self.location.replace(tmt_url_640);
}
}//tmtC_resolutionRedirectEnd

It is not working, however it is not causing any errors... anyone have any
thoughts...