简体   繁体   中英

How can I make an unordered list with browser information using JavaScript?

I am in a beginner HTML class and this I'm needing some help with my final assignment. My teacher is admittedly not the best at explaining things, so maybe I'm just confused? The function is pretty much using the Navigator object and will display information on the client's navigator in an unordered list. However, not really sure how to do that. I'm pretty much a beginner so any help with this would be very appreciated.

The homework instructions

try this:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <ul id="app"></ul>
  </body>
</html>
<script>
  const app = document.getElementById("app");

  for (let i in navigator) {
    let li = document.createElement("li");
    li.innerText = innerText =
      typeof navigator[i] === "string" && i + ": " + navigator[i];
    app.appendChild(li);
  }
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM