Detecting resolution of client browser

  • Thread starter Grzegorz Klimsa
  • Start date
G

Grzegorz Klimsa

Hi !
I have a problem wiht detecting resolution of client web browser
I prepare several files of css style for different browsers and different
resolutions,
(such as : Style_1024x768.css ; Styleff_1024x768.css; Style_1280x1024.css ;
Styleff_1280x1024.css )

I want to set css style file depends on resolution browser

I wrote this script to detect type of browsers, but i don't have any idea
how to detect resolution ???

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<script runat="server">

protected void Page_Init(object sender, EventArgs e)
{
// Define an HtmlLink control.
string type = Request.Browser.Type;
HtmlLink myHtmlLink = new HtmlLink();

if (type == "IE7")
{

myHtmlLink.Href = "Style_1280x1024.css";
myHtmlLink.Attributes.Add("rel", "stylesheet");
myHtmlLink.Attributes.Add("type", "text/css");
// Add the HtmlLink to the Head section of the page.
Page.Header.Controls.Add(myHtmlLink);
}
else
{
myHtmlLink.Href = "Styleff_10280x1024.css";
myHtmlLink.Attributes.Add("rel", "stylesheet");
myHtmlLink.Attributes.Add("type", "text/css");
// Add the HtmlLink to the Head section of the page.
Page.Header.Controls.Add(myHtmlLink);
}

}

Greetings
Grzegorz
 
J

Juan T. Llibre

re:
!> I want to set css style file depends on resolution browser

There's many ways to do that.

This Google search will help you find one you can use/adapt :
http://www.google.com/search?hl=en&q=detect+browser+resolution

re:
!> if (type == "IE7")
{
!> myHtmlLink.Href = "Style_1280x1024.css";

That someone uses IE7 doesn't mean that their
screen resolution is necessarily set to 1280x1024.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top