|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
RE: Browser information and Screen resolution
Quote:
You can't and that's a VERY GOOD THING!!!! Users still need some control over their OWN computer. |
|
#3
|
|||
|
|||
|
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... |
|
#4
|
||||
|
||||
|
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 |
|
#5
|
|||
|
|||
|
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>
|
|
#6
|
|||
|
|||
|
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> |
|
#7
|
|||
|
|||
|
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! |
|
#8
|
|||
|
|||
|
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. |
|
#9
|
||||
|
||||
|
RE: RE: Browser information and Screen resolution
Quote:
Would it be possible to set this up as a switch statement for easier readability, or no because you're comparing two variables? |
|
#10
|
|||
|
|||
|
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...
|
|
#11
|
|||
|
|||
|
RE: Browser information and Screen resolution
i will research the switch statement.
i am sorry CodeKadiya they are a little different |
|
#12
|
|||
|
|||
|
RE: Browser information and Screen resolution
whoops! that was me above
|
|
#13
|
|||
|
|||
|
RE: Browser information and Screen resolution
Quote:
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 |
|
#14
|
|||
|
|||
|
RE: Browser information and Screen resolution
You should consider adjusting the browser window size instead of screen resolution.
|
|
#15
|
|||
|
|||
|
RE: RE: Browser information and Screen resolution
Quote:
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!!!!!! |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Browser information and Screen resolution |
| Thread Tools | Search this Thread |