windows 如何让我的代码从USB在所有设备上工作?[duplicate]

ttcibm8c  于 2023-03-04  发布在  Windows
关注(0)|答案(1)|浏览(133)
    • 此问题在此处已有答案**:

Links broken on HTML file on thumbdrive(2个答案)
HTML not loading CSS(10个答案)
14小时前关门了。
我用一个U盘来保存我正在创建的一个概念网站的所有代码。我遇到了一个问题,我所有的按钮都被锚定到一个G:但是当我使用我的chromebook时,它不会将usb归为G:驱动器,它被归类为可移动媒体棒。所以没有一个按钮工作正常。此外,我不知道这是否与目前的主题,但我也认为我会提到,我使用的 * Chromebook * 是一个学校的Chromebook,所以我不能做任何Linux相关的,因为它确实有限制,它是管理员阻止。我只是认为我应该提到,我不是很擅长使用这个平台。我加入这个平台大约3天了,所以我是个新手。
我使用了一些JavaScript,我现在没有或不记得了。它是沿着如果文件一没有打开报告一个错误到一个控制台,并尝试打开文件二。我本来希望它尝试打开windows文件(文件一),当它找不到该文件时,它会尝试打开chrome文件一(文件二)和工作。
这是我目前的代码。(我改变了一些名称,因为它揭示了一些信息,我不想在网上,这是一个概念网站的一所学校)*编辑:哈,不好意思,我应该说得更具体些。我是说我的按钮。由于设备的改变,我的按钮不能指向正确的文件路径。
超文本标记语言

<div class="container">
<link rel="stylesheet" href="Homepage.css">
<script src="Homepage.js"></script>
<title>(schoolname) C </title>
<head> 
    <Div id="Info">
<p id="Infotext"> InformationAboutSchoolGoesHere</p>
</Div>
</head>
<body>
    <div id="imgmaindiv">
    <img src="https://th.bing.com/th/id/R.24cfe6cd3910c78823b3392b238b96fb?rik=d0P6PWa8DkHh4A&riu=http%3a%2f%2fi0.kym-cdn.com%2fentries%2ficons%2foriginal%2f000%2f003%2f338%2f320px--Insert_image_here-.svg.png&ehk=DiZEo3mrhc61UU55lzUVloegyab5VdeMjBBWsCSpvGU%3d&risl=&pid=ImgRaw&r=0" alt="Pic w/ Logo">
</div>
<div id="NavButtons">
<a href="G:\HomePage.html"><button style="vertical-align: middle"; id="Theactualbuttons">Home</button></a>
<a href="G:\Information\Info.html"><button style="vertical-align: middle" id="Theactualbuttons" id="Information">Information</button></a>
<a><button style="vertical-align: middle" id="Theactualbuttons">Curriculum</button></a>
<a><button style="vertical-align: middle" id="Theactualbuttons">Staff Directory</button></a>
<a><button style="vertical-align: middle" id="Theactualbuttons">Student Activities</button></a>
<a><button style="vertical-align: middle" id="Theactualbuttons">Organizations</button></a>
</div>
<div id="WelcomeM">
<p id="WelcomeMText1"> Welcome to Portage North Middle School </p>
<h1 id="WelcomeMText"> At (InsertSchoolName), we provide a safe and educational enviornment for our students along with fun. Our school welcomes you.</h1>
</div>
<div id="ChromebookRepair">
<h2 id="ChromebookRepairT">Chromebook Repair</h2>
<p id="ChromebookRepairT"> If your chromebook is broken please bring it to the front office. Before coming please fill out this form</a>. There may be a charge for repairing your chromebook depending on damage levels. Please try not to touch any forms of damage in case you get injured or damage your chromebook more. Please let our tech people handle it.
 </p>
 <img id="chromebookimage" src="https://i.ibb.co/MkSHNfQ/image-removebg-preview-1.png">
</div>
<div id="Events">
    <h2 id="eventstitle">Events</h2>
    <table class="table">
        <thead>
            <tr>
                <th class="table">Event</th>
                <th class="table">Event Time</th>
                <th class="table">Rescheduled?</th>
                <th class="table">Passed?<th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td class="table">Mid-Winter Break</td>
                <td class="table">RemovedForReasons</td>
                <td class="table">No</td>
                <td class="table">Yes</td>
            </tr>
            <tr>
                <td class="table">5th Grade Welcome Night</td>
                <td class="table">RemovedForReasons</td>
                <td class="table">Yes</td>
                <td class="table">No</td>
            </tr>
            <tr>
                <td class="table">Parent-Teacher Conferences</td>
                <td class="table">RemovedForReasons</td>
                <td class="table">No</td>
                <td class="table">No</td>
            </tr>
        </tbody>
        </table>
</div>
<div id="...Overview">
<img src="https://imagetolink.com/ib/7qTFL0fuOG.png" alt="NMS's Overview" id="NMSOverview1">
</div>
</body>```
xtfmy6hx

xtfmy6hx1#

获取带有JavaScript的操作系统并更改文件路径。

<html>

<body>
  <img id="img">
  <script>
    let fileName;

    const ua = window.navigator.userAgent;
    console.log(ua);

    if (ua.indexOf("Windows NT") != -1) {
      console.log("Windows");
      fileName = "file:///D:/neko.png"
    }
    else if (ua.indexOf("CrOS") != -1) {
      console.log("ChromeOS");
      fileName = "file:///media/removable/USB%20Drive/neko.png"
    }

    document.getElementById("img").src = fileName;

  </script>
</body>

</html>

相关问题