Reputation: 3171
Im writing a fairly small web application in PHP and intend on using DOJO to make it "fancy" and most likely handle some validation on the client side (there will be server side validation too).
I would like make JavaScript a requirement for my site, and therefore, if a user's browser has JavaScript disabled, or is not capable of JavaScript, they shouldn't be able to use the site at all, and get a message to notify them of this requirement.
I have seen other sites do this, but I can't work out how to enforce it.
For an example, attempt to log in here with username=user and password=user
http://demo.actitime.com/login.do?username=user
I would then want this same thing to happen on everypage.
Any help appreciated.
occhiso
Upvotes: 1
Views: 2061
Reputation:
The best reason I can think of is to stop people accessing and using forms without java scripted based browsers so hiding from the Counters.
For example if someone decides to spam, even with capcha and hides their isp by not enabling javascript, (alot of counters rely on it), then I think it would be a good idea to ban all non javascript browsers on a website.
In fact I think I will.
Good idea 'occhiso'.
Upvotes: 0
Reputation: 7429
You know, the year is 2009, not 1997. These hacks belong to the past, dead and buried like the filth they were.
As for a useful answer: read up on graceful degradation.
As for your answer: CSS can accomplish what you're doing with DOJO with no Javascript at all (at least, the things you mention). It would require roundtrips to the server if javascript isn't enabled, that's all. I don't know what you mean by 'logic', but the canonical sense of the term is better done with PHP and possibly a templating system than by using javascript.
Input validation without a roundtrip is nice, but if I have no javascript or can't use it, server validation is better than no-frickin-site at all.
Yes, it is really that bad.
EDIT: Colonel Sponsz points out another useful link about graceful degradation.
Upvotes: 5
Reputation: 5779
Some advanced users disable JavaScript by default, and enable it on a per-website basis. I would just warn them that JavaScript is required to go further. Use to dispaly the text to browsers without JS, or with JS disabled:
<noscript>
<p style="color: Red;">Warning: JavaScript is required to display anything after you login. Please enable JavaScript or use a different browser</p>
</noscript>
Upvotes: 1
Reputation: 395
Just put a script in your page that enables a session variable in the browsers that visit your site by redirect or submiting data using Ajax to the page that enables that variable. In the next click y the session does not have the session variable, you redirect it to another page, which one request a JavaScript enabled browser.
Upvotes: 1
Reputation: 3171
One reason is that I wanted a tabbed interface - which allows the same task to be done different ways. Alot of the same logic is used "per tab", so I didnt want to break it off to a separate page.
Using dojo, I can achieve this pretty easily by having all the content is separate div's on the same page, then dojo puts each div in it own tab. Without JavaScript, you would see all tabs (the divs) at once.
There are a few little hiccups like this, and I thought making it a requirement, it would always behave and look good, and those without JavaScript would miss out, baring in mind that this is by no means a mission critical site!
Also, this means I can enforce input validation without the user having to reload the page.
Is it really that bad?
Upvotes: 0
Reputation: 3580
The only appropriate response to this is: "Why would you want to?"
Really, a better approach would be to try making it work first, then adding the fancy javascript bits afterwards. This way users that have javascript disabled can still use it, even if it has limited functionality.
Upvotes: 4
Reputation: 53376
I don't think this is a sensible approach.
Just put a little more effort in the site so users without javascript can access the site too. Don't forget that they are your customers. And they probably have a good reason to disable javascript.
Upvotes: 21
Reputation: 625147
Two things spring to mind:
<noscript>
tags for content; andIn the case of that website and for similar functionality, instead of having a submit button, have a normal button with an onclick handler:
<input type="button" onclick="documents.forms[0].submit();" value="Submit">
Can't submit without Javascript enabled.
Upvotes: 4