当用户的Javascript关闭时,是否可以在网页上显示隐藏按钮?
我需要在我的网页上显示或隐藏一个Button元素,具体取决于用户是否打开他的Javascript ON。
我知道我可以在使用<noscript>
标记禁用JS时显示内容,但是如何在禁用JS时启用/禁用按钮。我基本上处理扩展/折叠类型的按钮场景,单击按钮会扩展/折叠内容。
有没有可能实现这个目标?
提前感谢您的回复。
答案 0 :(得分:1)
您最初可以隐藏按钮,然后立即使用javascript显示它。 e.g。
<button id="btn" style="display: none;">JS Button</button>
<script type="text/javascript">
document.getElementById('btn').style.display = "block";
</script>
答案 1 :(得分:1)
您可以设置如下链接或按钮:
<div id="buttonContent" style="display:none">
Button/Link content goes here.
</div>
然后,我们用Javascript显示:
<script type=text/javascript>
window.onload = function ()
{
document.getElementById('buttonContent').style.display = 'block';
}
</script>
这样,如果用户的javascript被禁用,则窗口不显示,如果你想要相反,只需开始显示它然后用JS隐藏它。