rellik
05-02-2003, 11:47 AM
OK, I have an iframe and wish the height of it to be, say 650px if the resolution of the users' screen is higher than 800x600. Can anyone help me?
cheers
cheers
|
Click to See Complete Forum and Search --> : JS to change iframe height rellik 05-02-2003, 11:47 AM OK, I have an iframe and wish the height of it to be, say 650px if the resolution of the users' screen is higher than 800x600. Can anyone help me? cheers AdamGundry 05-02-2003, 12:20 PM How about using this JS to generate the iframe? if (screen.height > 600){ document.write('<iframe height="650px">'); } else { document.write('<iframe height="300px">'); } Remember this will fail if Javascript is disabled, so setup appropriate <noscript> tags. Adam rellik 05-02-2003, 12:31 PM cheers, where do i put the <noscript></noscript> tags? within the <script>? or after? cheers pyro 05-02-2003, 12:34 PM After... This is the syntax: <script language="javascript" type="text/javascript"> //your script here </script> <noscript>You need to enable javascript</noscript> rellik 05-02-2003, 12:36 PM Can't i put <script language="javascript" type="text/javascript"> if (screen.height > 600){ document.write('<iframe height="650px">'); } else { document.write('<iframe height="300px">'); } </script> <noscript><iframe height="300px"></noscript> so that it would create the 'default' sized iframe? pyro 05-02-2003, 12:46 PM Here's now I'd do it, and it won't break for those without javascript -- it just will simply not resize the iframe. <html> <head> <script language="javascript" type="text/javascript"> function setvals() { if (screen.height > 600) { document.getElementById("myiframe").style.height = "600px"; } else { document.getElementById("myiframe").style.height = "300px"; } } </script> </head> <body onload="setvals()"> <iframe id="myiframe" style="height:300px;"></iframe> </body> </html> rellik 05-02-2003, 12:53 PM cheers fellas..wrked a treat ;) webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |