0

I have created a webpage using the InnerHtml function in JavaScript. I now want to import some icons into this JavaScript file.

These icons have come from an external site, which contains a CDN link.

How could I do this?

I have tried to write the CDN link inside the tags of the InnerHTML function, as well as in the HTML part of the InnerHTML function. However, neither way imports the icons correctly.

4
  • 1
    Can you please show us the code that isn't working, along with any debugging you've tried? This will help us get a better picture of your issue, and possibly get a better answer. Commented Jan 30, 2023 at 16:50
  • Have You tried the <i></i> Commented Jan 30, 2023 at 16:51
  • @FriedBrain <i> is the idiomatic tag (italics). I don't believe that to be relevant to this issue Commented Jan 30, 2023 at 16:53
  • stackoverflow.com/questions/2592092/… could you go through this it will work? Commented Jan 30, 2023 at 17:02

1 Answer 1

0

You can use <ion-icon></ion-icon> and specify the name in it like

<ion-icon name="home-outline" class="home-icon"></ion-icon>

Note: It works with ion-icons package only.

Simple example:

* {
  box-sizing: border-box;
}
<html>

<head>
</head>

<body>
  <div class="container">

    <ion-icon name="home-outline" class="home-icon"></ion-icon>

  </div>

  <script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
  <script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js">
  </script>
</body>

</html>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.