Browser information and Screen resolution

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
szms
Forum Contributor
Posts: 101
Joined: Thu Jun 26, 2003 12:23 pm

Browser information and Screen resolution

Post by szms »

I like to check which browser and what screen resolution user is using in his/her computer when the first time he/she browse the web site. How to do that?

Can I set his/her screen resolution according to my required resolution of the web site.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Try this:

Code: Select all

alert("Screen setup: " + screen.width + " x " + screen.height + ", " + screen.colorDepth + " bits per pixel\n" + "Browser: " + navigator.userAgent + " (" + navigator.appName + ")");
szms wrote:Can I set his/her screen resolution according to my required resolution of the web site.
I don't think it is possible.

Regards,
Scorphus.
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

szms wrote:Can I set his/her screen resolution according to my required resolution of the web site.
And if you could that would drive me nuts and I would never visit your site again.
User avatar
cybaf
Forum Commoner
Posts: 89
Joined: Tue Oct 01, 2002 5:28 am
Location: Gothenburg Sweden

Post by cybaf »

It is forbidden to do that in javascript, and as Paddy wrote you would not be very popular and I think that you should "rethink" your solution. However, if you really really want to change a user's resolution you could do it with a signed javascript. There is a tool called javascript signing tool that could be used. The user will then get an alert and a question to authorize your script.

search google for "javascript signing" and you should get some more help there.

but REMEMBER... changing the users resolution is NOT the way to go to solve the problem with a site looking different in different resolutions.

//cybaf
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Re: Browser information and Screen resolution

Post by McGruff »

szms wrote:Can I set his/her screen resolution according to my required resolution of the web site.
That would be a completely unaccepable intrusion into the end user's environment.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Re: Browser information and Screen resolution

Post by twigletmac »

McGruff wrote:
szms wrote:Can I set his/her screen resolution according to my required resolution of the web site.
That would be a completely unaccepable intrusion into the end user's environment.
Just want to add to this too - no, no, no, no, no.

Design your pages so that they fit into the user's environment (choice of browser, resolution etc) don't try and fit the user to yours. If you want everybody to see your pages the exact same way you do, do screenshots, print them and post them to those who want to see them.

Mac
Post Reply