JavaScript NOSCRIPT示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript NOSCRIPT示例相关的知识,希望对你有一定的参考价值。

This is just a quick sample that shows how to have a button visible on a page only if the person has javascript enabled.
  1. <!DOCTYPE html>
  2. <title>JavaScript NOSCRIPT Sample</title>
  3. body
  4. {
  5. margin: 0px;
  6. padding: 0px;
  7. background: url(http://static2.grsites.com/archive/textures/misc/misc221.gif);
  8. }
  9. .alphaBkg
  10. {
  11. position: fixed;
  12. width: 100%;
  13. height: 100%;
  14. background: #000;
  15. margin: 0px;
  16. padding: 0px;
  17. opacity: .5;
  18. -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
  19. filter: alpha(opacity=50);
  20. }
  21.  
  22. .modal
  23. {
  24. position: fixed;
  25. width: 250px;
  26. height: 40px;
  27. background: #cfcfcf;
  28. border: 4px solid #fff;
  29. left: 50%;
  30. margin-left: -125px;
  31. top: 50%;
  32. margin-top: -20px;
  33. text-align: center;
  34. }
  35.  
  36. .inputButton
  37. {
  38. font-size: 12px;
  39. width: 200px;
  40. height:42px;
  41. position: absolute;
  42. left: 50%;
  43. margin-left: -100px;
  44. top: 50%;
  45. margin-top: -21px;
  46. }
  47.  
  48. </head>
  49. <!-- Set the button to be invisible by default. I have done this with CSS -->
  50. <input type="button" id="sampleButton" value="Is your JS working?" onclick="alert('Yes! JavaScript Working!');" class="inputButton" style="display: none;" />
  51.  
  52. <script type="text/javascript">
  53. //This JavaScript fires if JS is enabled, making the button visible.
  54. document.getElementById('sampleButton').style.display = "block";
  55. <!-- If JavaScript is disabled the content in between the NOSCRIPT tages is displayed. -->
  56. <div class="alphaBkg"></div>
  57. <div class="modal">
  58. <span style="display: block; font-size: 12px; margin-top: 13px; font-family: arial, sans serif;">You don't have JavaScript Enabled!</div>
  59. </div>
  60. </body>

以上是关于JavaScript NOSCRIPT示例的主要内容,如果未能解决你的问题,请参考以下文章

noscript 是不是得到启用 javascript 的浏览器的确认?

Google 跟踪代码管理器集成安全性 - noscript iframe 沙盒

html PHP代码片段: - AJAX基本示例:此代码演示了使用PHP和JavaScript实现的基本AJAX功能。

Javascript中的noscript

如何在 DNN 代码隐藏中加载 Facebook Pixel NoScript 代码?

元刷新标签不使用 noscript 标签重定向