ColdFusion is run on the server side, and JavaScript is run on the client
side.  The serverside gets run first, so you can use ColdFusion to set
JavaScript variables, but you can't use JavaScript to access coldfusion
variables. But I do see a way around your particular problem, the code
follows:


<cfif NOT IsDefined("url.navLanguage")>
        <SCRIPT LANGUAGE="JavaScript1.2">
                if (navigator.appName == 'Netscape')
                        var language = navigator.language;
                else
                        var language = navigator.browserLanguage;
<cfoutput>
                document.location = 
"#cgi.script_name#?#cgi.query_string#&navLanguage=" +
language;
</cfoutput>
        </SCRIPT>
</cfif>

That should work as long as your not passing form variables into the page.
You need to throw that function into the body's onload attribute.

_________________________________________
Pete Freitag ([EMAIL PROTECTED])
CFDEV.COM / NETDesign Inc.
http://www.cfdev.com/

-----Original Message-----
From: Peter Theobald [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 15, 2000 1:07 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Javascript variables and Cold Fusion


Sorry for being redundant... I know there has been plenty of discussion on
this topic lately and I didn't read any of them :-(

How do I read a Javascript variable from Cold Fusion?
Specifically, I need to know the browser's language setting.
Here is what I would like to do:

<SCRIPT LANGUAGE="JavaScript1.2">
if (navigator.appName == 'Netscape')
var language = navigator.language;
else
var language = navigator.browserLanguage;

<CFSET Session.language = (javascript) language>

Obviously I can't do that because CF is executed on the server before the
page is ever sent, and Javascript is run by the browser on the client side.


---------------------------------------------------------------------------
Peter Theobald, Chief Technology Officer
LiquidStreaming http://www.liquidstreaming.com
[EMAIL PROTECTED]
Phone 1.212.545.1232 Fax 1.212.679.8032

----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to