最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Check if javascript is disabled? - Stack Overflow

programmeradmin1浏览0评论

If I have a website that makes use of javascript and the user will get the most full experience of the website if they have javascript enabled, but it would still be fully functional even if javascript was disabled. Is there a way to check if the user has javascript disabled for the browser they are using, so I can display a message of something like: "The website is best viewed with javascript enabled"

If I have a website that makes use of javascript and the user will get the most full experience of the website if they have javascript enabled, but it would still be fully functional even if javascript was disabled. Is there a way to check if the user has javascript disabled for the browser they are using, so I can display a message of something like: "The website is best viewed with javascript enabled"

Share edited Dec 12, 2010 at 17:45 IrishChieftain 15.3k8 gold badges52 silver badges95 bronze badges asked Dec 12, 2010 at 17:18 XaisoftXaisoft 46.7k87 gold badges285 silver badges444 bronze badges 1
  • 1 Afaik <noscript> isn't part of xhtml5 anymore since it doesn't play well with DOM. – CodesInChaos Commented Dec 12, 2010 at 17:35
Add a ment  | 

5 Answers 5

Reset to default 5

You could use the <noscript> tag:

<noscript>
    The website is best viewed with javascript enabled
</noscript>

You may also take a look at this article about unobtrusive javascript.

Use the HTML <noscript> tag in your view to display alternate content. Content between <noscript> and </noscript> will only be displayed if the browser has no JavaScript support or has JavaScript disabled.

Check the <noscript> HTML-Tag

The proper way to do this is to use Progressive Enhancement. Have a basic markup file that will work across all browsers. Then apply your JavaScript to browsers that understand JS emitted by a test suite:

http://code.google./p/enhancejs/

In ASP.Net we have Request.Browser.JavaScript in order to check whether browser support Javascript or not not but it does not check whether disable or enable.

There is an article on codeproject. describing a work around for same purpose. You can check it out at http://www.codeproject./KB/aspnet/Detect_JavaScript_in_ASPX.aspx.

发布评论

评论列表(0)

  1. 暂无评论
ok 不同模板 switch ($forum['model']) { /*case '0': include _include(APP_PATH . 'view/htm/read.htm'); break;*/ default: include _include(theme_load('read', $fid)); break; } } break; case '10': // 主题外链 / thread external link http_location(htmlspecialchars_decode(trim($thread['description']))); break; case '11': // 单页 / single page $attachlist = array(); $imagelist = array(); $thread['filelist'] = array(); $threadlist = NULL; $thread['files'] > 0 and list($attachlist, $imagelist, $thread['filelist']) = well_attach_find_by_tid($tid); $data = data_read_cache($tid); empty($data) and message(-1, lang('data_malformation')); $tidlist = $forum['threads'] ? page_find_by_fid($fid, $page, $pagesize) : NULL; if ($tidlist) { $tidarr = arrlist_values($tidlist, 'tid'); $threadlist = well_thread_find($tidarr, $pagesize); // 按之前tidlist排序 $threadlist = array2_sort_key($threadlist, $tidlist, 'tid'); } $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); $access = array('allowpost' => $allowpost, 'allowupdate' => $allowupdate, 'allowdelete' => $allowdelete); $header['title'] = $thread['subject']; $header['mobile_link'] = $thread['url']; $header['keywords'] = $thread['keyword'] ? $thread['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>