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

CF can only read variables that are sent back via an HTTP request. So, to
pass a variable from JavaScript to CF, you'll have to write JavaScript code
to request a cfm file. Here's an example, using the ternary conditional
operator, which is similar to CF's IIF function, instead of an if statement:

<script language="JavaScript">
        var mylanguage = (navigator.appName == 'Netscape' ? navigator.language :
navigator.browserLanguage);
        parent.otherframe.location.href = 'somefile.cfm?mylanguage=' + mylanguage;
</script>

Then, of course, you'd have to do something with URL.mylanguage in
somefile.cfm. In addition to appending variables as URL parameters, you can
also use JavaScript to programmatically submit forms.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

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