i want the page to load only if java script is enabled i am using html & php other than js . Dont suggest me <noscript> currently an setting a php variable $dis play =0 inside the <noscript> and using this variable to findout wheather to display or not but is there a better way
There is no other way ... but the way you do it is wrong because php runs at server and will run before the page is displayed to the visitor.. so your php variable will always get set.. what you normally do is to overlay (by default) a message that says that javascript is required and use javascript to hide this overlaid message.. if the user has javascript the overlay will be removed and the site will be working... if not then the overlay will remain in front of all other content and the user cannot do anything before activating javascript...
The noscript is fair play - but you only need to do it once and set it in your session. it is unlikely they will enable/disable js across pages. I have been thinking... not sure how practical it is but it may allow you to do something interactive as an alternative to JS... someone may disable it but leave shockwave/flash. now, all you need is a function defined in JS like... isJavascriptEnabled = function() { return true; };. create a small flash object and using the external interface in ActionScript (which itself is derived from the same ECMA roots as JS) you call that function and evaluate the response in order to do something as an alternative to JS; Or alert the user; or pass back a warning to your PHP session, letting you know you're flying blind =) To be honest, I have stopped trying to support sites for users that disable javascript, mostly because I have come to depend on it and look at it as an integral part of the page design and functionality but also, because it's their own fault. Yes, there also is a small percentage of visitors coming over on browsers like lynx or mobile or behind restricting corporate networking with javascript disabled or not even implemented. fair play but... there also is a thing known as "minimum requirements", a factor in every software development environment but somehow less so in web (which is probably wrong - as developers, we are still supporting IE6, a browser released in august 2001, instead of forcing people to upgrade). by analogy, you build a motorway, set the speed limit to 140 and add a minimum speed of 50. if a car is too knackered to sustain that speed or it's a tractor or a scooter etc, - the driver is EXPECTED to go elsewhere. they wouldn't expect me to build a side / slip road that allows them to get to their destination at their own pace... and yes, I am aware if it becomes a commercial decision and your business stands to lose a lot of money by not supporting javascript then you toughen it out and provide an alternative.
Maybe you can: - Hide the main content with display="none" - Show only the <div id="for_ppl_with_disabled_js"> with text "Please enable javascript to use this website" - Then use a javascript function to hide the <div id="for_ppl_with_disabled_js"> onload - Use javascript to show the main content If the user has disabled javascript, they only see contents in <div id="for_ppl_with_disabled_js"> But I don't think this is what you want, because: The page will still load and the content can be viewed in HTML source. There is no way a server-side language can know if the user's javascript is disabled during the first visit.
You've got the wrong mindset looking for JS to be disabled. Assume JS is disabled, and see it it's enabled. You can build a perfectly functional page that does not depend on any JS, and then use JS at the end to add the bells and whistles. If JS isn't enabled, the bells and whistles script simply will not run.
i just wnat to know if javascript is disable is that possible or not....Basically i want the user to be warned before he submits plz reply this query too http://forums.digitalpoint.com/showthread.php?t=1229865
Yes it's possible, if your script doesn't work it's disabled. How do you expect to find anything out if the language used to find things out isn't available ?