Results 1 to 13 of 13
-
04-13-2004, 10:11 PM #1Aspiring Evangelist
- Join Date
- Jan 2002
- Posts
- 428
PHP: Display depending on resolution
I run a skyscrape ad for AdSense on my site. The problem is, anyone with less than 1024x768 resolution has the problem where instead of displaying on the right side, ads are stuck at the bottom due to a lack or horizontal space.
I figure that the best way to get around this is is to have some PHP? that does something to the effect of grabbing the visitor's resolution and displaying the ad on the side if >=1024x768 and displaying a horizontal ad at the top only if resolution is less than that. Ideas?
-
04-13-2004, 10:35 PM #2Web Hosting Master
- Join Date
- Dec 2002
- Location
- NY, NY
- Posts
- 3,974
you can grab the resolution using javascript
webmaster A T 420th.com
What is my Itunes playing? Visit 420th.com/nowplaying.jsp to find out.
Ask the monkey: http://www.monkeyfaq.com
-
04-13-2004, 10:38 PM #3Aspiring Evangelist
- Join Date
- Jan 2002
- Posts
- 428
Originally posted by ilyash
you can grab the resolution using javascript
Assuming I have no programming skills, how would I do that?
-
04-14-2004, 03:46 AM #4Web Hosting Guru
- Join Date
- Nov 2003
- Location
- Ljubljana, Slovenija, Europe
- Posts
- 298
<script>
var windowHeight=window.height;
var windowWidth=window.width;
var windowLocationNew='somePageYouCall.php?height='+windowHeight+'&width='+windowWidth;
window.location=windowLocationNew;
</script>
or you could always try paying someone to do it for you
Airnine
-
04-14-2004, 01:56 PM #5Aspiring Evangelist
- Join Date
- Jan 2002
- Posts
- 428
Originally posted by airnine
<script>
var windowHeight=window.height;
var windowWidth=window.width;
var windowLocationNew='somePageYouCall.php?height='+windowHeight+'&width='+windowWidth;
window.location=windowLocationNew;
</script>
or you could always try paying someone to do it for you
Airnine
That script looks like it opens a new window or something like that?
What I am looking for is something like
If resolution < 1024x768 then display xxx
If resolution >= 1024x768 then display <blank>
-
04-14-2004, 07:40 PM #6Web Hosting Guru
- Join Date
- Nov 2003
- Location
- Ljubljana, Slovenija, Europe
- Posts
- 298
on from the code above...
just put:
if(windowHeight>768){window.location=somepage.php;}
else{window.location=somepageelse.php;}
-
04-14-2004, 10:42 PM #7Aspiring Evangelist
- Join Date
- Jan 2002
- Posts
- 428
Just an update for anyone in the future, here is the working code I used:
<html>
<head>
</head>
<body>
<script type="text/javascript">
var theAd = "larger res";
if((screen.width >= 1024) && (screen.height >= 768))
{
document.write(theAd);
}
</script>
<script type="text/javascript">
var theAd = "lesserres";
if((screen.width < 1024) && (screen.height < 768))
{
document.write(theAd);
}
</script>
</body>
</html>
-
04-14-2004, 10:52 PM #8Junior Guru Wannabe
- Join Date
- Jun 2001
- Location
- Partizansk, Russia
- Posts
- 74
What if JavaScript disablet on client side?
Is there any way to get client's screen resolution in that case?Regards,
SAV
-
04-14-2004, 11:01 PM #9Aspiring Evangelist
- Join Date
- Jan 2002
- Posts
- 428
Originally posted by sav
What if JavaScript disablet on client side?
Is there any way to get client's screen resolution in that case?
It is too much of a pain in the arse to design a site that looks the same across all browsers and configurations. I will make a reasonable effort, but if you don't even have JS installed, don't bother going to my site.
-
04-15-2004, 06:08 PM #10Web Hosting Master
- Join Date
- Nov 2001
- Posts
- 551
Originally posted by sav
What if JavaScript disablet on client side?
Is there any way to get client's screen resolution in that case?
you didn't say it had to be nice did you?
-
04-15-2004, 06:38 PM #11Web Hosting Guru
- Join Date
- Nov 2003
- Location
- Ljubljana, Slovenija, Europe
- Posts
- 298
well, no javascript, no fun
someone has javascript off, but flash is playing,... interesting, possible, but not very likely...
the fact is, I think I got that somewhere off this forums, 98% of the browser users never alter their settings except email settings, meaning they use the preset stuff, so javascript is on; even, if that is overstated, I think it is, 75% percent is a more likely number, it's still a lot... additionally chances are that, whoever switched the javascript off knows who to switch it on, too, so there's truly no real problem here...
to pcgamez; why check the height of the screen? wouldn't only the width be adequate?
regards,
Airnine
-
04-16-2004, 12:21 AM #12Web Hosting Master
- Join Date
- Nov 2001
- Posts
- 551
Originally posted by airnine
well, no javascript, no fun
someone has javascript off, but flash is playing,... interesting, possible, but not very likely...
but I looked it up and the actionscript is:
System.capabilities.screenResolution.x
System.capabilities.screenResolution.y
just FYI
-
05-28-2004, 01:41 PM #13New Member
- Join Date
- May 2004
- Posts
- 1
Error in Macromedia docs for System.capabilities...
I tried using System.capabilities.screenResolution.x, but it didn't work. I did a search on the web and found a page on Macromedia's site saying that their docs were wrong -- here's what I copied directly from their site:
System.capabilities.screenResolutionX
This entry should read: System.capabilities.screenResolutionX .(There should be no period following Resolution .)
System.capabilities.screenResolutionY
This entry should read: System.capabilities.screenResolutionY .(There should be no period following Resolution .)
If you'd like to see the full list of revisions in the docs, go to (Macromedia's main site -- www_dot_macromedia_dot_com)/support/flash/documentation/flash_mx_errata/flash_mx_errata03.html