gpt4 book ai didi

javascript - 如果 Javascript 不起作用,显示消息?

转载 作者:行者123 更新时间:2023-11-29 16:27:12 25 4
gpt4 key购买 nike

显示注释来代替脚本通常输出的内容的最简单方法是什么?

我目前有以下代码:

<p id="orderBy">
<script type="text/javascript">
<!--
// Array of day names
var dayNames = ["Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday"];
var nextWorkingDay = [ 1, 2, 3, 4, 5, 1, 1 ];
var now = new Date();
document.write("Order by 5pm today for dispatch on " +
dayNames[nextWorkingDay[now.getDay()]]);
// -->
</script>
</p>

(根据Display tomorrow's name in javascript?)

作为示例,上面的代码输出以下内容:

Order by 5pm today for dispatch on Monday

如果出于某种原因禁用了 javascript,我希望得到以下内容:

Order by 5pm for next working day dispatch

我该怎么做?

最佳答案

使用 <noscript> :

<noscript>
Order by 5pm for next working day dispatch
</noscript>

或者将文本放入普通元素中并使用 JavaScript 隐藏它。

关于javascript - 如果 Javascript 不起作用,显示消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4850777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com