javascript - 使 HTML/CSS/Javascript 无法在平板电脑上正常运行
问题描述
我用一些 CSS 和 JavaScript 编写了一些基本的 HTML。该代码要求用户输入密码,Javascript 验证密码并提醒用户所需的信息。此代码在我的桌面上正常运行,但只要我将文件添加到我的三星平板电脑,只会出现 HTML。我正在使用的代码如下。目前从同一个文件夹中运行所有文件,但希望将主 HTML 移动到平板电脑主页,并将 CSS 和 Javascript 留在另一个位置,但仍被引用。
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="dowlingcss.css"/>
<title>
Dr. Dowling
</title>
</head>
<body>
<script src="dowlingjs.js"></script>
<img src="parasol.jpg" alt="Parasol Logo" height="250" width="750">
<h1>Welcome Dr. Dowling</h1>
<p>What is the answer?</P>
<form>
<input id="pass">
<button type="button" onclick="myfunction()">Login</button>
</form>
</body>
</html>
Javascript
function myfunction()
{
var x, text;
//Get the value of the input field with id="pass"
x = document.getElementById("pass").value;
var password = x.toLowerCase();
// If x is Not = to fatluke
if (password != "fatluke")
{
alert("incorrect");
}
else {
alert("The CD is in room 125 under the bed");
}
}
解决方案
在此代码块中添加您的代码以运行并在页面加载后检查
window.onload = (function () {
// insert your code here
});
另外,尝试使用“window.getElementById()”,我认为这取决于您的浏览器和平板电脑上的网络视图版本。
推荐阅读
- youtube - 无法确定 Youtube 数据 API 的配额单位成本
- office-js - 如何使用 Office.js 在线读取/写入 Excel Online 和 PowerPoint 中的自定义属性?
- python - Graphene Django 按通用关系过滤
- python - 在 Keras 中,如何获取 LSTM 层的 3D 输入和 3D 输出
- c# - 为什么 Html.PassowordFor 将占位符打印为乱码?
- r - 如何使用 rpart.plot 在树状图中显示没有指数值的整数(例如:income>29e+3)?
- git - git中的闹鬼图像
- android - Android Q:在android java.lang.NoSuchMethodError中使用bubble时出错
- machine-learning - 从类似于另一个较小数据集的数据集中对实例进行分类的算法,其中这个较小的数据集代表一个类
- c# - Scrape Website 与 POSTMan 一起使用 C# 失败