We help IT Professionals succeed at work.

Getting Screen resolution for a CSS

1,480 Views
Last Modified: 2013-11-07
Hi Experts!!!
I have learnet how to get the screen resolution width and height from my clients using javascript( screen.width = 1280; screen.height = 1024;)

Is there a way to change a CSS file knowing the screen resolution of the client?  So I can change my web page,depending of their resolutions. I have a web page that doesn't have scroll bar when is watch from a resolution of 1280*1024 but when I see the same page in 1280*768 the browser scrollbars appear.I don't want that. I don;'t like scrollbars!!..Any help please...and Would you mind using examples?...
I am using Asp.net 2.0 and c#..

Thank you so much for allll yourrr HELP!!!!!

Comment
Watch Question

Commented:
if ((w >= 720) && (w <= 920)) {
document.write('<link rel="stylesheet" href="720.css">');
}

Author

Commented:
Thanks!! Could you exaplin a little bit more ? Please
if(screen.width >=720) && (screen.width <=920)
{
 document.write('<link rel="stylesheet" href =" MyStylesheet.css')
}
Inside of  my MyStylesheet.css, in how or on  which variable do I need to  save so on the load page this variable can command to resize the page for the client screen depending of their monitor?

I don't know if I need to use  javascript coding to do this or execute it in C#
Thanks spambler for your fast answer!!!!

Commented:
View the source of the following page I created and you'll see a similar function I used for setting the height of an iframe.

http://www.griffithsandarmour.com/professional.asp

Author

Commented:
hi!!
Would you mind to give me a example a little more simple? Please.... I sore it of can understand the source but...something a little more simple, please !!!
Thanks so much

Commented:
if(screen.width >=720) && (screen.width <=920)
{
 document.write('<link rel="stylesheet" href =" MyStylesheet.css')
}

This is saying that if the screen width is greater than or equal to 720 AND less than or equal to 920 then load a certain stylesheet.

Of course... you could scrap all the above and place your page in a table with a set width of 100%.  Deciding the height of a page is the tricky part.  As an example I could have google toolbar, crawler toolbar and whatever other toolbars so my actual visible browser window will be smaller than somebody with zero toolbars.  

The other option is to force full screen on the user i.e. the same a pressing F11.  (Try it now!).

Author

Commented:
Okey...Well If I udnerstand this right.
I need to create to CSS files. The first one for the 1024*768 and the other one for 1280*1024, is this right? Now I have three tables in my file. The middle one has a background picture and also this is the one that I am going to resize new height and width depending of CSS file.

I want that the picture in the background resize with the size of the table;. I know that I need to use 100% to do this.
Could you pleas give me an example, how to use the 100% from CSS file and how to write the dimention of the table from CSS files?
Thanks... I really appreciate your help
The F11 is awesome but not clue how to do that....

Author

Commented:
I mean two Css files!! sorry about that!!
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you so much!!.. But my boss says that the pages need the button Back and Forward from the Browser... I think I resolve my proble, I create a customize javascript that tell the client to change the screen resolution. I know is awfull but I have been watching on the web and there is not any web page that doesn't have this problem. Sorry for bother you!..I can give you this points if you want to.
I have a Emergency question  EMERGENCY!!!!URGENT!!!  in this URL:
https://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22776453.html

In case that you can help me with this one I will reallyt appreciatet!!...Thank you so much for your help. No one has touched so far! Looks pretty hard.
The question is about how to Call  and create an  AJax Modal Pop up Extender from Java, and passing Session values which are going to appear in the modal Pop up extender..
For example a client select a city and later one on tjhe click of the button continue and Javascript ALERT  will pop up  showing the name of the city that they selected. I want to take out this javascript and create the Ayax Modal Pop Up Extender  that will do the same. My problem is that i don't know how to pass the name to teh city to the Pop Up extender. Is this make sence?....Anyhow ...Difficult question but has 500 points!! Could you help me with that one? and tell me if you want the points for this question.

Thanks soooooo much spambler!!!

Commented:
Hey, I'll never say no to the points.  I could call a popup with toolbar and close the parent if that would help?  Plenty of examples on the web for that.

Author

Commented:
I haven't found any one!!! Woudl you mind send me an example!! with the code that I send you ..please!! and about the point ..you get it!!
Thanks

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.