?
Solved

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

Posted on 2004-03-26
8
Medium Priority
?
2,656 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
  • 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
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
Suggested Courses

840 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