This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Clientside script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Clientside script" Watch "Clientside script" New topic
Author

Clientside script

sundar sankaran
Greenhorn

Joined: Aug 10, 2004
Posts: 10
Javascript code will be executed on clientside. What happen when user disable the javascript? Whether all the browser will run the Ajax code???
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Lets see...Ajax = JavaScript

JavaScript Disabled = JavaScript does not run

SO since Ajax = JavaScript that means you already answered your question.

I think there is a better quesiton in this saying: If the user disables JavaScript, what steps can I take as a developer to make sure that these users are not let out in the cold?

Now that is a better question!

Eric
Neerav Narielwala
Ranch Hand

Joined: Dec 08, 2006
Posts: 106
The solution: <noscript> and <meta> tags.

I place the following in the HTML Head Content (inside the <head> tag for you web-heads out there that, like me, hand-write your own DHTML!):

<noscript>
<meta http-equiv="refresh" content="0;url=status.html">
</noscript>
The <noscript> tag, as per W3Schools.com is described below:

"The noscript element is used to define an alternate content (text) if a script is NOT executed.

This tag is used for browsers that recognizes the <script> tag, but does not support the script in it."
So what we're doing here is redirecting the user agent based on their ability to recognize the <script> tag, but failure to do anything about it (due to, for example, the user agents lack of functionality which you'll find in some WAP/Mobile browsers, or a very capable user agent with Javascript disabled).

As for the destination (read: now that I know you can't use my beautiful UI, where do I send you?!), this is where Google and I part company. Google Maps simply redirects to a page that tells the user that their browser is not currently supported - which IMHO will only confuse the user, as if they only disabled Javascript on their browser, they're likely to find their browser amongst the "Support Browsers" listing. No, I recommend a modification of another method I talked about a while back: An Attempt at Dynamic Content via Javascript

Using this method, you can have your application redirect to status.html with various "status codes", yielding various dynamic/context-sensitive messages to the user agent. Of course, this heavily utilizes Javascript, but you can display the following as the default content in your status.html:

If Javascript is disabled or otherwise not available, the innerHTML of the content container is not changed, and therefore this message is displayed to the user and becomes a reliable redirect/status/landing area for your web-based applications!


<a href="http://www.java-tips.org/java-tutorials/tutorials/" target="_blank" rel="nofollow">Java Tutorials</a> | <a href="http://www.planet-java.org" target="_blank" rel="nofollow">Java Weblog</a> | <a href="http://computer-engineering.science-tips.org" target="_blank" rel="nofollow">Computing Articles</a>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
And what if Meta Refresh is disabled.

If you want to see something interesting. Goto Google's Gmail with JavaScript disabled. That is all Ajax based and it works!

Eric
 
jQuery in Action, 2nd edition
 
subject: Clientside script
 
Similar Threads
how to use jsp variables in javascript
how to call js file from jsp
file opens in new window, but need in parent window
send mail using javascript
opening a new window from servlet