Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 18th, 2009, 09:08 PM
Authorized User
 
Join Date: Dec 2008
Posts: 50
Thanks: 1
Thanked 5 Times in 5 Posts
Default Need help with javascript function??

Hi All

My question is

Isn't there a JavaScript function to tell me if JavaScript is turned on or not?

Your help will be much appreciated.

Thanks in advance

Regards
 
Old February 19th, 2009, 12:19 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Ummm...and if it is turned *OFF* then what good is the function? You can call it as much as you want and since JS is turned off, nothing will happen.

Yes, you can detect *ON THE SERVER* if JS is turned on or not, pretty easily. Various ways.

My favorite is to simply do something like this:
Code:
<form action="nextPage.asp" onSubmit="this.jsEnabled.value='YES'; return true;">
<input type=hidden name="jsEnabled" value = "NO">
...
</form>
That target action can of course be .asp, .aspx, .php, .jsp, or whatever server side coding you are using.

Or you could do this (lots of my friends do it, and it works for HTML-only sites as well as ASP/JSP/et al.):
Code:
<form action="nextPageWithOUTjs.html" onSubmit="this.action='nextPageWITHjs.html';">
...
</form>
You can also, of course, have HTML appear ONLY when scripting is OFF via:
Code:
<script>
.... stuff with JS coding ...
</script>
<noscript>
<h1>You must turn on JavaScript for these pages to work!</h1>
</noscript>

Last edited by Old Pedant; February 19th, 2009 at 12:21 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
stop current javascript function using javascript sakthi Javascript 3 June 2nd, 2008 03:30 PM
Calling a javascript function from C# SebFr C# 0 November 3rd, 2006 12:05 PM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
get value from javascript function suzila ASP.NET 1.0 and 1.1 Basics 6 December 3rd, 2005 10:38 AM
Problem with a Javascript function SuMajestad PHP How-To 4 August 17th, 2004 09:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.