Solved

Coldfusion - detect visitor's pc resolution - (screen size)

Posted on 2004-03-26
8
2,546 Views
Last Modified: 2013-12-20
Can anyone tell me how I can detect the visitor pc's screen size/resolution?
I've searched ee and found a mention below:

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_11971698.html

but they say it can only be done in javascript.? excuse ignorance ... but how do I pass the javascript variable into that of a CF variable?

I'm a total newbie .. so.


In other words ... I'm trying to determine the width & height of client pc screen size.

Thanks much!
Richard Buchanan
The Opinion Exchange
www.opinion-exchange.com

0
Comment
Question by:rcbuchanan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 17

Expert Comment

by:Tacobell777
ID: 10691640
1st what is the reason for wanting to know the resolution and pass it on to ColdFusion?

Then to pass any variable from JavaScript o ColdFusion you'll have to make a new page call, either with GET or POST, you can pass the variable you want coldfusion to know about via the URL or as a FORM field, i.e.
http://somedomain.com?myjsvariable=a test

OR
PSUEDO code
<form ........>
<input type="hidden" name="myjsvariable" value="a test">
<input type="submit ........>
</form>

Then in coldfusion you can reference to these variables like so

#url.myjsvariable# or #form.myjsvariable#

Does that help and make sense?
0
 
LVL 2

Expert Comment

by:Cypher188
ID: 10692649
Hi
couldnt you just use the cfscript tag to set a CF variable?

eg....
<cfscript>
      function ListFix(list) {
               
        list = replace(list,"#delim##delim#", "#delim##null##delim#", "ALL");
        list = replace(list,"#delim##delim#", "#delim##null##delim#", "ALL");
        
      }
</cfscript>

list being the variable?

Good luck.
Chris
0
 

Author Comment

by:rcbuchanan
ID: 10692663
guys:
i feel compelled to inform you that i'm BEYOND newbie.
I'm CF self-taught ... with bad habits and missing gaps.
 ...
i'm truly lost on this one! ListFix!?
R.
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 17

Expert Comment

by:Tacobell777
ID: 10692733
You and me too, I am lost too, I can't see how what Cypher suggests has anything to with your question, no offense Cypher...

Simple answer to your question, ColdFusion can only talk to CF if you GET or POST variables to CF, i.e. you pass the js variables to it via url or form variables.

To detect screen resolution you would need to use JavaScript
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20269725.html?query=screen+resolution&searchType=topic
0
 
LVL 2

Expert Comment

by:Cypher188
ID: 10692799
Hi
Sorry that was some code that i used in a completey differnet app, I have spent some time trying to work your answer out but it looks like im at a lost

http://lists.evolt.org/archive/Week-of-Mon-20010716/037364.html

you have to pass the information through a url effectivly reloading your page.

I presum this is for different templates of your site, the only idea i could give you is to load a small window or something to detect the browser size.

Sorry I cant be much more of a help
Good luck
chris
0
 
LVL 11

Expert Comment

by:hart
ID: 10693535
client related stuff can be detected using javascript.

after detecting it assign it to a form hidden field and submit the form.
on the next page u can use this value as a normal form.field.

and to detect screen resoltion , its one line code for getting the width and height.

Regards
Hart
0
 
LVL 5

Accepted Solution

by:
Seth_Bienek earned 500 total points
ID: 10704977

You can only detect browser resolution using client-side (ie JavaScript) programming.  There are two ways to get the data from client-side code to CF: by passing the data in the URL, or by posting the data in a form.

If you have a login page on in your app, then a good way to do this is using the form-based approach.  Just add a hidden form element (or two) within your <form> tags on the login page:

<input type="hidden" name="screenprops" value="">

And then some Javascript to populate the hidden form field with the screen information you want, further down the page (toward the end is good):

<script type="text/javascript" for="window"  event="onload()">
  document.form1.screenprops.value = screen.width + ' X ' + screen.height + ' (' + screen.colorDepth + ')';
</script>

Then, when the user submits the login form, the hidden form field gets passed along with the login information to the login action page as form.screenprops.

This has been the more straightforward approarch in my experience.  If you want instructions on doing it via url forwarding, or if you have any questions about this approach, just holler.

Also, as a caveat, the javascript provided here has been simplified for illustrative purposes, and some error-checking and cross-browser compatibility code has been removed.

Take Care,

Seth
0
 

Author Comment

by:rcbuchanan
ID: 10763022
Ok, finally got to a position in development to actually apply this answer to my code!
All I can say is VERY VERY cool!

Thank you very much!
Richard Buchanan
The Opinion Exchange
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Web Development Tools for MVC 3 125
Finding an Azure real-time monitoring dashboard 2 91
Systems talking to each other 5 148
SonicWall port forward 4 17
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question