【问题标题】:Issue with Javascript on IOSIOS上的Javascript问题
【发布时间】:2020-07-14 10:11:12
【问题描述】:

今晚我有一个非常令人困惑的案子!

所以我正在用 Java Script 制作一个聊天机器人(有点)。它看起来像一个老式的操作系统。

我添加了一个聊天命令,用户说“你住在哪个国家”,然后它回复“[澳大利亚]”。我在我的桌面上测试了这个,一切都很好!然后我在我的 iPad 上运行它,它显示了我的错误提示,然后我直接将 Mac 命令复制并粘贴(Apple 设备的通用剪贴板)到 IOS 提示符中,但它仍然失败。我很困惑为什么会这样。任何帮助,将不胜感激。注意:我在我的 2 台试用设备上运行 IOS 14 Beta,但是我在非 IOS 14 设备 (13) 上尝试过仍然同样的问题。另请注意,由于放置在 JS 中的过滤器,标点符号和大小写无关紧要。但这很可能是我的问题。

网站: https://sam-neale.github.io/Net-OS/ 相关命令:您来自哪个国家/地区

var prevTextCache;
var prevTextCacheC;
var prevTextCacheF
var scrn = document.getElementById("compscrn");
var d = new Date();
var t = d.getTime();
function cacheTextRunProgram(){
    //Cache Text
    prevTextCache = scrn.value;
    prevTextCacheC = prevTextCache.toUpperCase();
    prevTextCacheF = prevTextCacheC.replace(/[.,\/#!$’‘%\^&’\*;:{}=\-_'`~()]/g,"");
    console.log("textCached");
    //Run a program
    if (prevTextCacheF == "HI" || prevTextCacheF == "HEY" || prevTextCacheF == "HELLO"){
        scrn.value = prevTextCache + " [Hey there!]";
        console.log("Ran command");
    }else if (prevTextCacheF == "WHATS THE TIME"){
        scrn.value = prevTextCache + " [" + d + "]";
        console.log("Ran command");
    }else if (prevTextCacheF == "WHATS YOUR NAME"){
        scrn.value = prevTextCache + " [My Name is Net Bot]";
        console.log("Ran command");
    }else if (prevTextCacheF == "WHATS YOUR AGE" || prevTextCacheF == "WHEN WERE YOU BORN"){
        scrn.value = prevTextCache + " [I was made on 14 July 2020]";
        console.log("Ran command");
    }else if (prevTextCacheF == "WHAT COUNTRY ARE YOU FROM"){
        scrn.value = prevTextCache + " [I was made in Australia]";
        console.log("Ran command");
    }else{
        scrn.value = prevTextCache + " [Sorry I don't understand]";
        console.warn("Ran into issue running command command, Code: 0001");
    }
}
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
*{
    margin: 0;
    padding: 0;
    font-family: "VT323";
    background-color: black;
}
textarea{
    width: 100%;
    font-size: 20px;
    border:none;
    background-color: black;
    color: green;
    font-family: "VT323";
    padding-left: 5px;
    padding-right: 5px;
    padding-top: 1px;
    padding-bottom: 1px;
    outline: none;
}
button{
    width: 100%;
    height: auto;
    border:none;
    color: white;
    height: 20%;
    font-size: 20px;
}
button:active{
    background-color: green;
}
<!DOCTYPE html>
<html>
<head>
    <title>Net OS</title>
    <link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
 <textarea rows="30" id="compscrn" value="demo"></textarea>
 <button onclick="cacheTextRunProgram()">Run Function</button>
<script type="text/javascript" src="script.js"></script>
</body>
</html>

【问题讨论】:

  • 我在台式机上试一试总是说:[对不起,我不明白]
  • '你住在哪个国家'没有多余的行。
  • 同样的问题。抱歉跑题了
  • 好吧,我现在更困惑了,我从本地 git 复制了最新的 dat 代码(不需要提交/推送)并将其粘贴到程序中。错误,所以现在我真的很困惑
  • 而且...本地版本(存储在我的计算机上的版本可以使用)而网站上的版本没有。所以我认为这是一个 GitHub 问题?

标签: javascript html ios


【解决方案1】:

好吧,这是火车残骸,我没有做任何更改,神奇的是,IOS 现在可以工作了。

总结: 问 Mac 本地版本何时可以运行,Mac 上的网站何时可以正常运行,但 IOS 上的网站已损坏。 然后Mac上的网站坏了。 然后不知从何而来,Mac上的网站正在运行, 然后IOS上的网站就可以正常工作了。

我相信这是 github 的错,因为在某一时刻本地版本可以工作,但网站不能。感谢所有的帮助。我要去睡觉了,因为我的大脑刚刚坏了。

【讨论】:

  • *不是真的 我很早就做了一个更改,我留下了一些意外的代码来尝试解决问题,但在删除之后它仍然坏了
猜你喜欢
  • 1970-01-01
  • 2015-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-06
  • 1970-01-01
  • 2011-11-30
  • 2018-06-19
相关资源
最近更新 更多