PDA

View Full Version : Question about browsers and javascript



Richard
05-04-2007, 07:46 PM
Hello Guys,

I am no expert in javascript - quite the opposite. But perhaps there is someone on this forum who can help me out :) . I create websites for restaurant online ordering. The online ordering system is pretty unique in that it actually makes no use of javascript. This way customers who have javascript blockers on their browsers (e.g. large companies) can still order through our system.

However I am very aware of the benefits of javascript in improving our product. Does anyone know if it is possible to detect whether a browser is blocking javascript and then direct the user to a particular page depending on the response. I have NO IDEA if this kind of thing is at all possible, but I wanted to ask.

Thanks and enjoy your day!

Richard

Twey
05-04-2007, 08:13 PM
It's possible, but unwieldy. A much better solution is to build a single page that makes use of Javascript in such a way that if Javascript is disabled, the page can still be used.

Richard
05-04-2007, 09:23 PM
Thanks for your reply. I'm not sure how to go about doing what you suggest - but it sounds a logical thing to try. I want to have a calendar on my page that customers can select a date from. If the customer is blocking javascript, I want to be able to have them select a date from a drop down menu.

boxxertrumps
05-04-2007, 09:40 PM
<noscript>
stuff that replaces js, like the form elements...
</noscript>
The form elements wont be included and will be hidden when JS is turned on, and the opposite when JS is turned off.

Richard
05-04-2007, 09:47 PM
Thanks, that's useful!:)

Twey
05-04-2007, 09:54 PM
The other (less intrusive) method is to have the <select> by default, then have a script on the page hide the <select> and display the calendar instead.

Richard
05-04-2007, 10:11 PM
I like both suggestions, but I don't know enough about scripts to know how to hide the <select> tag.:confused:

Twey
05-04-2007, 10:42 PM
There's a nice tutorial (http://www.howtocreate.co.uk/tutorials/javascript/important) over at www.howtocreate.co.uk (http://www.howtocreate.co.uk/).

mwinter
05-05-2007, 02:49 PM
<noscript>
stuff that replaces js, like the form elements...
</noscript>
The form elements wont be included and will be hidden when JS is turned on, and the opposite when JS is turned off.
And you're screwed if scripting support is enabled (and it doesn't even have to be javascript!) yet the user agent is not capable of executing the script properly. This is why the noscript element is a waste of time. Follow Twey's suggestion: dynamically modify the page via scripting.

Mike