Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Detect javascript enabled

0 views
Skip to first unread message

plarts

unread,
Oct 17, 2005, 5:13:17 AM10/17/05
to
Is there a way for CF to detect if the client navigator have
javascript enabled ?

Thanks for answers.

Pierre.

Neculai Macarie

unread,
Oct 17, 2005, 8:03:08 AM10/17/05
to
plarts wrote:
> Is there a way for CF to detect if the client navigator have
> javascript enabled ?

One way would be to redirect the user to different pages if he has or not
javascript:
<html>
<head>
<meta name="Refresh" content="4; URL=no_javascript.cfm" />
</head>
<body onload="window.location.href='with_javascript.cfm';">
</body>
</html>

--
<mack />


Dan Bracuk

unread,
Oct 18, 2005, 12:12:48 AM10/18/05
to
Maybe something like this:
<script language="javascript">
function testjs(){return true;}
</script>

<cftry>
<body onload="return testjs();">

<cfcatch>
code for no javascript

Neculai Macarie

unread,
Oct 18, 2005, 3:43:30 AM10/18/05
to

This will not work because cftry is executed on the server side and the
javascript is executed on the client side.

--
<mack />


Gomba

unread,
Dec 16, 2005, 7:53:49 AM12/16/05
to
After so many years of taking from these forums it's nice to be able to finally
give something back. Pierre: I had the same question and here's how I solved
it. On the login page to my app I used JS to set the value of a hidden field to
(entitled JSVal) to yes. When the user logs in, I pass the hidden field to the
next form and if the value is set to Yes then I allow the user to continue. If
the value is set to blank, meaning JS didn't run because it wasn't enabled, the
user is redirected (using CFLocation) to another page and told to enable JS. I
did this on every page in my app in case someone got in and then turned JS off
(probably not likely, but I'm paranoid). Here's the code for the first two
pages and the error page

Login Page
<html>
<BODY onLoad="JSChk>
<SCRIPT LANGUAGE="JavaScript">

function JSChk()
{
document.myform.JSVal.value = "Yes";
}

</SCRIPT>

<FORM Method="Post" Name="myform" Action="Welcome.CFM">
<INPUT TYPE="hidden" NAME="JSVal">
<TABLE ALIGN="center">
<TR>
<TD>NT ID</TD>
<TD><Input Name="strUserName" Type="Text"></TD>
</TR>
<TR>
<TD>Password</TD>
<TD><INPUT TYPE="password" NAME="strUserPassword"></TD>
</TR>
<TR>
</TR>
</Table>
<Div Align="Center">
<BR>
<INPUT TYPE="submit" VALUE="Submit">
</DIV>
<BR>
</FORM>
</body>
</html>


Welcome Page
<html>
<BODY onLoad="JSChk>
<SCRIPT LANGUAGE="JavaScript">

function JSChk()
{
document.WelcomePage.JSVal.value = "Yes";
}

</SCRIPT>

<FORM ACTION="LogPage.cfm" Name="WelcomePage" METHOD="post">
<CFIF Form.JSVal NEQ "Yes">
<CFLOCATION URL="http://www.ms.com/Logs/Logout.cfm?JSVal=No">
</CFIF>
<INPUT TYPE="Hidden" NAME="JSVal">
</FORM>
</BODY>
</HTML>


Logout Page
<html>
<BODY>
<CFIF (IsDefined("URL.JSVal"))>
You're browser does not have Javascript enabled and this is required in order
to access the IS&S Contract Log Pages. Please correct this and click <A
HREF="./adminlogon.cfm">here</A> to return to the login screen.
<CFABORT>
</CFIF>

0 new messages