Solved

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

Posted on 2004-03-26
8
2,506 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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 manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
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. …

772 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