Is there a PHP code for this? |
Author: |
Message: |
Woraug
Full Member
A Credit to Dementia
Posts: 128 Reputation: 2
36 / / –
Joined: Sep 2006
|
O.P. Is there a PHP code for this?
Basically, what I'm wanting to do is have varying backgrounds for my site. I want to have the code detect what resolution whoever is visiting the site, and set a specified image as the background. If I set a small image as the background, it doesn't look good tiled or stretched. If I set a big image as a background, you can't see the whole thing, or it looks terrible downsized.
|
|
12-10-2006 02:49 AM |
|
|
Menthix
forum admin
Posts: 5537 Reputation: 102
40 / /
Joined: Mar 2002
|
RE: Is there a PHP code for this?
AFAIK resolution can only be detected with javascript. PHP will certainly not work, PHP runs serverside, the resolution is clientside.
Keep in mind that there is a big difference between screen resolution and browser window resolution.
I personally wouldn't fill the background with one big image, it probably wont look good when a user resizes the window while viewing your page and keep a watch on the filesize of the image.
|
|
12-10-2006 03:02 AM |
|
|
Nathan
Veteran Member
Yeah, "large dimensions" ;)
Posts: 2984 Reputation: 76
– / /
Joined: Apr 2005
|
RE: Is there a PHP code for this?
Meh you dont even need javascprt you can use css
|
|
12-10-2006 03:05 AM |
|
|
Menthix
forum admin
Posts: 5537 Reputation: 102
40 / /
Joined: Mar 2002
|
RE: Is there a PHP code for this?
CSS can't detect the user's screen resolution or browser window resolution, and that was what he asked for. Correct me if i'm wrong.
|
|
12-10-2006 03:07 AM |
|
|
Nathan
Veteran Member
Yeah, "large dimensions" ;)
Posts: 2984 Reputation: 76
– / /
Joined: Apr 2005
|
RE: Is there a PHP code for this?
No but it can stretch to the width and height of the browser and thats all he wants from what i see.
|
|
12-10-2006 03:08 AM |
|
|
Menthix
forum admin
Posts: 5537 Reputation: 102
40 / /
Joined: Mar 2002
|
RE: Is there a PHP code for this?
quote: Originally posted by Nathan
it can stretch to the width and height of the browser
quote: Originally posted by Woraug
it doesn't look good tiled or stretched.
|
|
12-10-2006 03:10 AM |
|
|
Nathan
Veteran Member
Yeah, "large dimensions" ;)
Posts: 2984 Reputation: 76
– / /
Joined: Apr 2005
|
RE: Is there a PHP code for this?
Hmm sorry,
My bad
|
|
12-10-2006 03:12 AM |
|
|
rav0
Veteran Member
i have an avatar
Posts: 1419 Reputation: 29
35 / /
Joined: Aug 2003
|
RE: Is there a PHP code for this?
I'd just but a big image as the backgroud, and if a user has their browser window smaller (or as big as it goes, but their screen resolution is low), let the image be cropped.
You should be able to see most of the image, and you can't detect the exact size of the page, just the screen rosolution, so there will be a border or cropping unless you end up being really lucky. The background is only in the background anyway.
| |
(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination
|
|
12-10-2006 05:00 AM |
|
|
stu
Junior Member
Stu
Posts: 82 Reputation: 1
39 / /
Joined: Sep 2004
|
RE: Is there a PHP code for this?
you could just use a script that detects what res they are using and redirect them to an appropriate page. not to sure how to just change the background picture though. To redirect them just use something like
code: <script language="JavaScript">
<!--
if ((screen.width>=1024) && (screen.height>=768))
{
window.location="highres.html";
}
else
{
window.location="lowres.html";
}
//-->
</script>
enter whatever values you want for the width and height
|
|
12-19-2006 03:09 AM |
|
|
Woraug
Full Member
A Credit to Dementia
Posts: 128 Reputation: 2
36 / / –
Joined: Sep 2006
|
O.P. RE: Is there a PHP code for this?
What would I do to that code to make it do like:
if resolution = 1024x768: redirect to background1.jpg
if resolution = 1280x1024: redirect to background2.jpg
if resolution = 1600x1200: redirect to background3.jpg
ect.
Sorry, me and coding don't get along very well
|
|
12-19-2006 10:20 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|