gpt4 book ai didi

Chrome 和 Internet Explorer 中的 javascript 数组

转载 作者:行者123 更新时间:2023-11-28 12:47:37 25 4
gpt4 key购买 nike

我有这段代码,它在 Google Chrome 中工作,但在 Internet Explorer 中不起作用。

<html><head>
<script type ="text/JavaScript">
<!--
function status()
{
var text = newArray();
text[0] = "Life is traveled only once..Today's moment becomes tomorrow's memory..Enjoy every moment; good, bad, happy, or sad;because the gift of life is LIFE itself";
text[1] = "never design your character like a garden where any one can walk. but design your character like the sky, where everyone likes to reach you";
text[2] = "Crying is never a symbol of weakness... From the time we are born, it has always been a sign that we are alive...";
text[3] = "If you believe, you can achieve!";
text[4] = "BELIEVE: To hope for the best, endure the stress, passing every test & accepting nothing less.";
text[5] = "Never give up on your dreams and goals, if you do,your life end up no where.";
text[6] = "The only thing that is guaranteed forever is your family... they will always be your family.. everything else can change.";
var i = Math.floor(7*Math.random())
var g=window.alert(text[i]);
return g ;
}
//-->
</script>
</head></html>

最佳答案

newArray(); 应该是 new Array(); 甚至更好,[]

此外,JavaScript 字符串中不能有换行符 - 请用 \n 替换物理换行符。

返回 alert() 的返回值也是没有意义的。

关于Chrome 和 Internet Explorer 中的 javascript 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6002183/

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