SunQuest
           Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old October 9th, 2003, 11:38 AM
szms szms is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 107 szms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Browser information and Screen resolution

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.


Reply With Quote
  #2  
Old October 9th, 2003, 12:06 PM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,320 tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 10700 Folding Title: Novice Folder
Time spent in forums: 6 Days 8 h 46 m 16 sec
Reputation Power: 4
RE: Browser information and Screen resolution


Quote:
Can I set his/her screen resolution according to my required resolution of the web site.



You can't and that's a VERY GOOD THING!!!! Users still need some control over their OWN computer.

Reply With Quote
  #3  
Old October 9th, 2003, 12:17 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Browser information and Screen resolution

Take a look at this page, it is a good place to learn Javascript. Since most of your questions are javascript related, I thought I would recommend it...

http://www.pageresource.com/jscript/index2.htm

You should be able to find the answer there...

Reply With Quote
  #4  
Old October 13th, 2003, 03:40 AM
bluephoenix's Avatar
bluephoenix bluephoenix is offline
Levelheaded Curmudgeon
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Syracuse, NY
Posts: 507 bluephoenix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 13 m 2 sec
Reputation Power: 2
Send a message via AIM to bluephoenix
RE: Browser information and Screen resolution

screen.height and screen.width will return the user's screen resolution.
Code:
 <script type='text/javascript'>
  w = screen.width;
  h = screen.height;
  document.write('The resolution is: ', w, '×', h);
</script>


You will not be able to change the user's resolution; such functionality has intentionally been left out of JavaScript for security reaons.

Also, you may want to consider the reasons people adjust their system to different resolutions... some may only have a monitor/graphics card only able to display certain resolutions, or the viewer may set their resolution lower due to a visual imparement.

Instead, use the values to adjust your page display to meet the viewer's needs and preferences (DHTML and CSS).

-Tim

Reply With Quote
  #5  
Old October 13th, 2003, 06:08 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: Browser information and Screen resolution

No, You cannot set the users resolution according to your required resolution.... What you can only do is change your website resolution according to user's resolution.

This will solve the first part of your problem.
Code:
<html>
<head>
<title>User Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table border=1 cellpadding=0 cellspacing=0>
<tr><td bgcolor="#bfbfbf" align="right">
<script language="JavaScript">
var ary=new Array("appCodeName", "appName", "appVersion", "mimeTypes", "plugins", "userAgent", "javaEnabled()+''", "X", "width+''", "height+''", "colorDepth+''", "X", "history.length+''");
var box=new Array("<input type='text' size=30 value='","'>", "<select onchange='more(this,this.form);'>", "", "<input type='text' size=6 value='","'>");
cnt=0; fmtcnt=0; var bgn=new Array("navigator","screen","window");
for(i=0;i<ary.length-2;i++) {
b=0; if(ary[i+cnt]=="X") cnt++;
val=eval(bgn[cnt]+"."+ary[i+cnt]); fmt="<br>n";
l=val.length; if(l>0) {
if(val.toString().indexOf('Array',0)>-1) {
val=""; b=2; box[3]="</select>"+box[4]+eval(bgn[cnt]+"."+ary[i+cnt]+".length")+box[5];
for(j=0;j<l;j++)
val+="<option value="+i+">"+eval(bgn[cnt]+"."+ary[i+cnt]+"["+j+"].description").substring(0,30); };
if(ary[i+cnt].indexOf("+''",0)>0) {
b=4; fmtcnt=(fmtcnt+1)%3; if(fmtcnt>0) fmt="n";
ary[i+cnt]=ary[i+cnt].substring(0,escape(ary[i+cnt]).indexOf('%')-1); };
document.write(ary[i+cnt]+":"+box[b]+val+box[b+1]+fmt);
   }
}

function more(sel,frm) {
frm.ta.value=""; cnt=1; nm=navigator.mimeTypes; ssi=sel.selectedIndex;
if(display(sel,frm,nm,ssi)==1)
for(k=0;k<nm.length;k++)
if(isEnabled(k))
if(isEnabled(k).name==navigator.plugins[ssi].name) {
frm.ta.value+=cnt+")."; cnt++
display(frm.elements[3],frm,nm,k);
   }
}

function display(sel,frm,nm,ssi) {
which=sel.options[ssi].value-3;
var prms=new Array();
prms[0]=new Array("mimeTypes","description","suffixes","type","enabledPlugin.name");
prms[1]=new Array("plugins","description","filename","length","name");
ln=5; if(which==0) if(!isEnabled(ssi)) ln=4;
for(i=1;i<ln;i++)
frm.ta.value+=prms[which][i]+":"+eval("navigator."+prms[which][0]+"["+ssi+"]."+prms[which][i])+"n";
return which;
}

function isEnabled(n) {
return navigator.mimeTypes[n].enabledPlugin;
}
</script>

<br>
</td></tr>
</table>
</center>
</body>
</html>

Reply With Quote
  #6  
Old October 13th, 2003, 06:36 PM
decka decka is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: NJ
Posts: 19 decka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to decka
RE: Browser information and Screen resolution

szms,

you can do it pretty easy in javascript. it is basic and just displays a messgage but maye u can work off of it. here is the code along with alot of the screen resolutions:


<script language="JavaScript">
<!--
if ((screen.width==1600) && (screen.height==1200)) {
document.write('<p align="center">Your screen resolution is 1600 X 1200. The recommended size to view this site is 1024 X 768.</p>');
}

else if ((screen.width==1280) && (screen.height==1024)) {
document.write('<p align="center">Your screen resolution is 1280 X 1024. The recommended size to view this site is 1024 X 768.</p>');
}

else if ((screen.width==1280) && (screen.height==768)) {
document.write('<p align="center">Your screen resolution is 1280 X 768. The recommended size to view this site is 1024 X 768.</p>');
}

else if ((screen.width==1280) && (screen.height==960)) {
document.write('<p align="center">Your screen resolution is 1280 X 960. The recommended size to view this site is 1024 X 768.</p>');
}

else if ((screen.width==1152) && (screen.height==864)) {
document.write('<p align="center">Your screen resolution is 1152 X 864. The recommended size to view this site is 1024 X 768.</p>');
}

else if ((screen.width==1024) && (screen.height==768)) {
document.write('<p align="center">Your screen resolution is 1024 X 768. It is the recommended size to view this site.</p>');
}

else if ((screen.width==800) && (screen.height==600)) {
document.write('<p align="center">Your screen resolution is 800 X 600. You should get with the program here. Everyone uses 1024 X 768. You will not be able to view this site properly.</p>');
}

else if ((screen.width==640) && (screen.height==480)) {
document.write('<p align="center">Your screen resolution is 640 X 480. I didnt know people still used that. The recommended size to view this site is 1024 X 768.</p>');
}

else {
document.write('<p align="center">Your screen resolution can not be detected. The recommended size to view this site is 1024 X 768.</p>');
}
//-->
</script>

Reply With Quote
  #7  
Old October 13th, 2003, 11:42 PM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: Browser information and Screen resolution

decka,

What's the difference between my code and your one? My code has some additional features too... .like browser information, which was needed by the original poster!

Reply With Quote
  #8  
Old October 14th, 2003, 12:00 AM
szms szms is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 107 szms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Browser information and Screen resolution

CodeKadiya,

In your first reply you said:
"What you can only do is change your website resolution according to user's resolution."

If different user has different resolution how do
I change my web site according to different user's resolution.


Reply With Quote
  #9  
Old October 14th, 2003, 12:08 AM
bluephoenix's Avatar
bluephoenix bluephoenix is offline
Levelheaded Curmudgeon
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Syracuse, NY
Posts: 507 bluephoenix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 13 m 2 sec
Reputation Power: 2
Send a message via AIM to bluephoenix
RE: RE: Browser information and Screen resolution

Quote:
Code:
<script language="JavaScript">
<!--
if ((screen.width==1600) && (screen.height==1200)) {
 document.write('<p align="center">Your screen resolution is 1600 X 1200. The recommended size to view this site is 1024 X 768.</p>'); 
}

else if ((screen.width==1280) && (screen.height==1024)) {
 document.write('<p align="center">Your screen resolution is 1280 X 1024. The recommended size to view this site is 1024 X 768.</p>'); 
}
...


Would it be possible to set this up as a switch statement for easier readability, or no because you're comparing two variables?

Reply With Quote
  #10  
Old October 14th, 2003, 11:07 AM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Browser information and Screen resolution

I know you can use multiple conditionals in the Select Case command in VB script (same as the JS switch command) by seperating the values with a comma, but have never tried it with JS...I will have to give it a try...I will report back...

Reply With Quote
  #11  
Old October 15th, 2003, 01:29 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Browser information and Screen resolution

i will research the switch statement.


i am sorry CodeKadiya they are a little different . no hard feelings?

Reply With Quote
  #12  
Old October 15th, 2003, 01:30 PM
decka decka is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: NJ
Posts: 19 decka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to decka
RE: Browser information and Screen resolution

whoops! that was me above

Reply With Quote
  #13  
Old October 15th, 2003, 03:53 PM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: Browser information and Screen resolution

Quote:
CodeKadiya,

In your first reply you said:
"What you can only do is change your website resolution according to user's resolution."

If different user has different resolution how do
I change my web site according to different user's resolution.


There is something more than what you think about this thing! What I mean is first you can check which resolution user comes from and include a proper style sheet to suit his resolution

Reply With Quote
  #14  
Old October 15th, 2003, 04:05 PM
mugane mugane is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Charlottesville, VA USA
Posts: 425 mugane User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to mugane Send a message via Yahoo to mugane
RE: Browser information and Screen resolution

You should consider adjusting the browser window size instead of screen resolution.

Reply With Quote
  #15  
Old October 15th, 2003, 04:13 PM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: RE: Browser information and Screen resolution


Quote:
You should consider adjusting the browser window size instead of screen resolution.


What I tell is to include different style sheets after checking the resolution Or redirect the user to a suitable page.

Not to change the users resolution!!!!!!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Browser information and Screen resolution


Thread Tools  Search this Thread