How to not all user to continue when javascript is disabled in the browser

StackOverflow https://stackoverflow.com/questions/12443890

  •  02-07-2021
  •  | 
  •  

سؤال

i have a login page and i want a user to not go further if Javascript is disabled. I tried to use noscript tag but the page UserId, Password fields and Login button does appears with the noscript message...How to completely blur the background with an alert and continue only after the user enables the Javascript...

Thanks for your help.

هل كانت مفيدة؟

المحلول

Hide elements with CSS (display: none). Show them with JS. You can make it a class and give that class to all the elements you want hidden.

Use JS to remove that class from those elements to show them. See this answer for how.

Now you won't see the login form unless you have JS. You won't be able to show a JS style alert (that'd require JS, wouldn't it...), but you can hide everything and show a message on the page.

نصائح أخرى

You can show a page-sized div which lies above all other content with an opaque (or semi-transparent) background in a <noscript> block, so that the login form appears below the div.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top