javascript and an alternative to "hidden"

SarcasticDwarf

Diamond Member
Jun 8, 2001
9,574
2
76
I currently have the below code to not display a banner if the users resolution is >=1024x768. The problem is, the "hidden" attribute still takes up space on the screen, making the formatting look all wrong. Is there an alternative to this I can use so that it won't display anything, even a space?

<script type="text/javascript">
if((screen.width >= 1024) || (screen.height >= 768))
{
document.getElementById('google').style.visibility = "hidden";
}
</script>
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Try setting its width and height properties to 0. And display to "none" while you're at it. (I forget the difference, but I generally just do both visibility:hidden and display:none)
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
display = none means its not even there.
visibility = hidden means it still takes up the same amount of space just it can't be seen.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
if its not already in a div tag you can do that an set innerHTML to &amp;nbsp; The only set back is I dont think all browsers support innerHTML
 

SarcasticDwarf

Diamond Member
Jun 8, 2001
9,574
2
76
Originally posted by: jonmullen
if its not already in a div tag you can do that an set innerHTML to &amp;nbsp; The only set back is I dont think all browsers support innerHTML

it is, and displaying a space will screw up formatting.
 

SarcasticDwarf

Diamond Member
Jun 8, 2001
9,574
2
76
I tried the following, but it won't display at all regardless of resolution.

<script type="text/javascript">
ad properties
</script>
<div name="theAd" id="google" align="center">
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<script type="text/javascript">
if((screen.width >= 1024) || (screen.height >= 768))
{
document.getElementById('google').style.display = "none";
}
</script>
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
I don't know, but this works for me by its self. I tried it at 800x600.
 

SarcasticDwarf

Diamond Member
Jun 8, 2001
9,574
2
76
This is the url. What should be happening is the vertical banner on the right should only display at >=1024x768 and the horizontal banner above the login box should only be displaying at <1024x768. Instead, the vertical banner is displaying regardless, and the horizontal never displays. I am thoroughly confused.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Your problem is that you have two ads with the Id "google" change one of the Ids to "googlea" an one to "googleb" or whatever you want. Also, please use double quotes for properties. :)