Vis Network

Other

HTML in titles

HTML parsing in titles has been disabled due to covert XSS issues (i.e. it was really easy to introduce XSS vulnerability into your project by accident). If you want to parse HTML anyway, you can still do it as the title accepts HTML elements.

But I just want to maintain white space


function preTitle(text) {
  const container = document.createElement("pre");
  container.innerText = text;
  return container;
}

// create an array with nodes
var nodes = new vis.DataSet([
  {
    id: 1,
    label: "PRE",
    title: preTitle("ASCII\n    art"),
  },
]);
      

But I just want my HTML to be parsed as it used to be


function htmlTitle(html) {
  const container = document.createElement("div");
  container.innerHTML = html;
  return container;
}

// create an array with nodes
var nodes = new vis.DataSet([
  {
    id: 1,
    label: "HTML",
    title: htmlTitle(
      "Go wild <'span style='display: inline-block; animation: be-tacky 5s ease-in-out alternate infinite; margin: 5px;'>!<'/span>"
    ),
  },
]);