| View previous topic :: View next topic |
| Author |
Message |
rhaul82
Joined: 22 Nov 2005 Posts: 3
|
Posted: Tue Nov 22, 2005 4:23 am Post subject: Resolution detection in HTML |
|
|
I'm new to HTML and have a quick question-
I am working on an html page and would like the banner to change corresponding to the resolution. for example, if the resolution of the viewer is 1024x768, i want to show the 1024 banner. if the resolution is 800x600, i want to show the 800 banner.
So, my questions being-
1. How can i do a resolution detection in html?
2. how can i include if conditions- ex- if(res == 800) show banner 800 else show banner 1024.
I looked online and all the info i found was relating to java scripts. but the page i'm working on is an HTML page.
I option i think might work is using an java applet to detect the resolution. but i don't know how to modfiy/edit the applet and use its output in a conditional.
Any ideas?????
Thanks in advance. |
|
| Back to top |
|
 |
|
|
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
Posted: Tue Nov 22, 2005 4:34 am Post subject: Re: Resolution detection in HTML |
|
|
this can be done fairly easily using php. Here is an example using cookies:
http://www.phpbuddy.com/article.php?id=8
I know there are many ways of doing this, probably some better than this. I'd read up on php.
Good Luck
-Mike |
|
| Back to top |
|
 |
rhaul82
Joined: 22 Nov 2005 Posts: 3
|
Posted: Tue Nov 22, 2005 4:44 am Post subject: screen res |
|
|
| How the hell do i integrate php code in my html file?? I have a .html page. I don't have a server or anyting. this is just a plain ol html website. |
|
| Back to top |
|
 |
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
Posted: Tue Nov 22, 2005 4:51 am Post subject: Re: Resolution detection in HTML |
|
|
I guess php won't work then if it has to be a html file. you need php installed in order to use it. Using just html you will probably have to do something with javascript or something. There is an option in html to use % as width instead of a fixed width, but that assumes you use the same banner and not three different sizes. Sorry I'm not too much help on this one.
Good luck
-Mike |
|
| Back to top |
|
 |
webmaster Site Admin

Joined: 17 Aug 2004 Posts: 3614 Location: Sweden
|
Posted: Tue Nov 22, 2005 10:20 am Post subject: Re: Resolution detection in HTML |
|
|
First of all I would like to welcome you to DEVPPL. So, welcome to DEVPPL
Here's a solutions that will work:
| Code: |
<script language="JavaScript1.2">
var screen_height = screen.height;
if (screen_height >= 768) {
document.write('<img src="test.jpg" width="1000" height="200" />');
} else {
document.write('<img src="test.jpg" width="800" height="150" />');
}
</script> |
Last edited by webmaster on Tue Nov 22, 2005 6:48 pm; edited 1 time in total |
|
| Back to top |
|
 |
rhaul82
Joined: 22 Nov 2005 Posts: 3
|
Posted: Tue Nov 22, 2005 6:39 pm Post subject: thanks |
|
|
| Thanks bunches. worked likea charm. |
|
| Back to top |
|
 |
|