It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

Resolution detection in HTML

Resolution detection in HTML

Postby rhaul82 on Tue Nov 22, 2005 3:23 am

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.
rhaul82
 
Posts: 3
Joined: Tue Nov 22, 2005 3:14 am

Postby mwa103 on Tue Nov 22, 2005 3:34 am

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
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm

screen res

Postby rhaul82 on Tue Nov 22, 2005 3:44 am

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.
rhaul82
 
Posts: 3
Joined: Tue Nov 22, 2005 3:14 am

Postby mwa103 on Tue Nov 22, 2005 3:51 am

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
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm

Postby webmaster on Tue Nov 22, 2005 9:20 am

First of all I would like to welcome you to DEVPPL. So, welcome to DEVPPL :)

Here's a solutions that will work:
Code: Select all
<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 5:48 pm, edited 1 time in total.
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

thanks

Postby rhaul82 on Tue Nov 22, 2005 5:39 pm

Thanks bunches. worked likea charm.
rhaul82
 
Posts: 3
Joined: Tue Nov 22, 2005 3:14 am


Who is online

Users browsing this forum: No registered users and 7 guests