I need to pass the screen height and width to coldfusion variables, so I can output the value in a link. e.g. <a href="http://mysite/myfolder/?keepThis=true&TB_iframe=true&height=<cfoutput>#height#</cfoutput>&width=<cfoutput>#width#</cfoutput>" class="smoothbox" title="mypage">mypage</a> Code (markup): My problem is how can I get javascript screen.height stored as the coldfusion variable #height# ? Thanks in advance for your advice.
Javascript runs _after_ all ColdFusion code is already finished. So you cannot do this on the same page/request. You need to use separate pages (or ajax). The first page would grab the screen height using javascript, and pass that value to the second page, in either a form field or as a url variable. Page 1: <script> ... document.href = "http://yoursite.com/page2.cfm?height"+ jsHeightVariable; </script> Then the second page will have access to #height# as a either a URL or FORM variable, depending on which method you used on page 1: Page 2: #url.height# ... or #form.height#
The only problem with doing what cfstarlight says is that if your index page is just a script that get the screen size and pushes it to another page your SEO is going to go way down. Search engines do not like re-routing like that on the Home Page.
Who asked about SEO? The question was about javascript and the answer is correct. It cannot be done in a single request.