首页 > 解决方案 > 使 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");
}
}

标签: javascriptandroidhtmlcsstablet

解决方案


在此代码块中添加您的代码以运行并在页面加载后检查

window.onload = (function () {
// insert your code here
});

另外,尝试使用“window.getElementById()”,我认为这取决于您的浏览器和平板电脑上的网络视图版本。


推荐阅读