Solved

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

Posted on 2004-03-26
8
2,493 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 17

Expert Comment

by:Tacobell777
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 2

Expert Comment

by:Cypher188
Comment Utility
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
Comment Utility
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
Comment Utility

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
Comment Utility
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 up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now