File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Avoiding Site Breakage Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Avoiding Site Breakage" Watch "Avoiding Site Breakage" New topic
Author

Avoiding Site Breakage

john gere
Greenhorn

Joined: Mar 10, 2011
Posts: 22
I am running a nice javascript that slides image up instead of the fade in and fade out. The problem is that when 'JavaScript' is disabled in the browser the site breaks. All the images show on the site, one under the other. I tried using a javascript enabled test script. This script shows one div when javascript is enabled and hides the other. The reverse happens when javascript is disabled. Here is the actual javascript:

This is the body tag

This is the div with the images:

This is the alternative div without the image rotation


I am looking for ways to prevent my site from breaking when javascript is disabled. The funny thing is, the site where I got the script from they have achieved the feat. I just don't know how: Here is the site I got the script from:
JavaScriptSite
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

This is called "graceful degradation", and it's rather an art. You want to structure your HTML such that if JavaScript is disabled, the site can still function using the default actions of links and forms.

The widgets of jQuery UI work in this way. If JavaScript is enabled to instrument the constructs, users get the full experience. Otherwise, things still "work" but in a more basic and clunky fashion.

On the other hand, you can just disallow entry into the site if JavaScript is disabled. This is what I generally do.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
john gere
Greenhorn

Joined: Mar 10, 2011
Posts: 22
I am looking for a solution that does not involve any third party software. I am already using jQuery. There should be an answer that does not involve frontMan. However, I will keep your application in mind. Thanks for the option
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

arima kidd wrote:I am looking for a solution that does not involve any third party software.

Who said anything about using 3rd party software? My mention of jQuery UI is an an example. It's all about how you structure the markup, not what JavaScript libraries you are using,

There should be an answer that does not involve frontMan.

And who even mentioned FrontMan at all?

john gere
Greenhorn

Joined: Mar 10, 2011
Posts: 22
No offence Bear Bibeault, but I a looking for a solution. Not a classroom vague 'You're on the right path' answer.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

There is no absolute solution. As I said, the approach is to structure the markup such that it works without any script instrumentation. Then you can add script to apply a more advanced user experience.

If you are waiting for a single, more specific answer that will apply to all situations, you'll be disappointed.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
john gere wrote:No offence Bear Bibeault, but I a looking for a solution. Not a classroom vague 'You're on the right path' answer.


Code the page so it functions the way you want with JavaScript disabled, than add in the features you want with JavaScript enabled.

Eric
 
 
subject: Avoiding Site Breakage
 
Threads others viewed
JSP and Ajax interaction
need help in jquery
what to do, if I get error `breaking on JScript rumtime error - object expected
image preview
a jquery plugin (not THE struts2-jquery plugin) not being loaded with struts2 mvc framework
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture