2

I know how to test upon page load or refresh if JS is enabled, but it is possible to do this at every reflow?

Say a page loads while JS is enabled, but during the browser session it is disabled, after which point any JS dependent actions performed by the user will fail. After testing I found for example that Chrome needed a refresh before these changes took effect while Firefox applied them instantly - so the site that originally worked fine broke when JS was disabled and no fallbacks that come into effect at page load were initiated.

Some may call this a trivial issue, and I am sure there are fallbacks that could solve this issue, but is it possible to test the state of the page at every reflow?

Any further ideas/suggestions/fallback examples welcome. Non-JQuery most welcome. Thanks!

user1360809
  • 725
  • 2
  • 13
  • 24
  • I am curious of a scenario where an answer to this question would be useful? – Tibos Mar 23 '14 at 21:25
  • See http://stackoverflow.com/questions/7006152/how-do-we-investigate-how-many-times-a-browser-is-doing-reflows for related information. – Etheryte Mar 23 '14 at 21:26
  • Would be helpful if you tell use what you use `to test upon page load or refresh if JS is enabled` and why this would not work on reflow for you. Because using ` – t.niese Mar 23 '14 at 21:29
  • @t.niese - in firefox I have a noscript and it did not apply in the scenario presented in the opening question. – user1360809 Mar 23 '14 at 21:50

1 Answers1

0

If/when JS is disabled on a page, there is no client side action you can take in order to "fix" your page. You can't associate something like a handler, because with JS disabled, it won't run.

Generally, sites that want to provide fallbacks for disabled JS work by using JS to augment the functionality not to be the functionality.

Here is a limited, but creative/hacky/original way to recover if JavaScript was suddenly disabled:

Put in the DOM an invisible link that covers the full page. The link is to a version of the page that doesn't need JavaScript (at worst a page informing the user that he must enable JavaScript). Obviously, the default action for the link is disabled via JavaScript. Re-trigger all the events happening on it to the elements underneath with JavaScript. Whenever JavaScript is disabled, any subsequent click will navigate away to the no-script page. Obviously this doesn't work with any other event than clicks and it is quite a bother, but it's the closest you can get to what you're after.

Another idea would be to manipulate meta-redirects with JavaScript (have a redirect that always occurs after 1 second, then with JS change it to occur after 1 more second, etc), but apparently that doesn't work.

Community
  • 1
  • 1
Tibos
  • 27,507
  • 4
  • 50
  • 64