开发者

JavaScript enabled/disabled in browser

开发者 https://www.devze.com 2023-01-05 17:50 出处:网络
How to find whether a user has 开发者_Go百科enabled or disabled JavaScript in the browser or the browser does not support JavaScript?Actually this is no direct way to detect javascript enable/disable.

How to find whether a user has 开发者_Go百科enabled or disabled JavaScript in the browser or the browser does not support JavaScript?


Actually this is no direct way to detect javascript enable/disable. Go through below article explain how to detact javascript enable or disable

Detect if JavaScript is enabled in ASPX


There is no way, but it shouldn't concern you.

Design your pages so they work properly without any javascript. When you're done, add unobtrousive javascript that will "override" links or submits behaviour so the js enabled users will get the nice js features, and for those with no js support the site will nicely degrade to the standard features.


There is not really a reliable way to do this. Besides it's up to the user of the browser to enable javascript or not. Try to make your site in such a way that it downgrades gracefully to a state where it doesn't have to support javascript but still can have the most important functionality.

Html also provides the < noscript> element in which you could state to the user that (s)he could turn on javascript to have a better experience. But still it's up to him/her to do so.


You can a <script> tag to that sends users to a page that uses Javascript.

For example: (in your <head>)

<script type="text/javascript">
    location.replace("JavaScript-Enabled.aspx");
</script>

However, the proper way to handle this is to allow your pages to work both with and without Javascript.


There isn't really a stable way, but you could do something like having Javascript send a message to your server which will set a flag there. If the message is not sent, you know Javascript is disabled.

0

精彩评论

暂无评论...
验证码 换一张
取 消