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.
<!DOCTYPE html> <html> <head> <style> body { margin: 0px; padding: 0px; background: url(http://static2.grsites.com/archive/textures/misc/misc221.gif); } .alphaBkg { position: fixed; width: 100%; height: 100%; background: #000; margin: 0px; padding: 0px; opacity: .5; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; filter: alpha(opacity=50); } .modal { position: fixed; width: 250px; height: 40px; background: #cfcfcf; border: 4px solid #fff; left: 50%; margin-left: -125px; top: 50%; margin-top: -20px; text-align: center; } .inputButton { font-size: 12px; width: 200px; height:42px; position: absolute; left: 50%; margin-left: -100px; top: 50%; margin-top: -21px; } </style> </head> <body> <!-- Set the button to be invisible by default. I have done this with CSS --> <input type="button" id="sampleButton" value="Is your JS working?" onclick="alert('Yes! JavaScript Working!');" class="inputButton" style="display: none;" /> <script type="text/javascript"> //This JavaScript fires if JS is enabled, making the button visible. document.getElementById('sampleButton').style.display = "block"; </script> <noscript> <!-- If JavaScript is disabled the content in between the NOSCRIPT tages is displayed. --> <div class="modal"> </div> </noscript> </body>
以上是关于JavaScript NOSCRIPT示例的主要内容,如果未能解决你的问题,请参考以下文章
noscript 是不是得到启用 javascript 的浏览器的确认?
Google 跟踪代码管理器集成安全性 - noscript iframe 沙盒
html PHP代码片段: - AJAX基本示例:此代码演示了使用PHP和JavaScript实现的基本AJAX功能。