Home > Software design >  'showPDF' is declared but its value is never read
'showPDF' is declared but its value is never read

Time:08-10

some background information: i have a button in my html file that should activate the showPDF function but it tells me that its value is never read

picture of the error message

javascript:

HM.PDFViewer = 
{
    init: function()
    {
        //---
    },
    showPDF: function()
    {
        function showPDF(x) {
            x.style.display = "none";
            var embed = document.createElement("EMBED");
            embed.setAttribute("src", "/pdf/Doku.pdf");
            embed.classList.add("size");
            document.body.appendChild(embed);
          }
    },
};

the button in my html looks like this:

<button type="button" id="show" onclick="showPDF(this)" >PDF anzeigen</button>

help would be greatly appreciated as i can't seem to find any answers in different questions

CodePudding user response:

You just need to remove the duplication of the showPDF function. you don't need the inner one.

showPDF: function()
{
        x.style.display = "none";
        var embed = document.createElement("EMBED");
        embed.setAttribute("src", "/pdf/Doku.pdf");
        embed.classList.add("size");
        document.body.appendChild(embed);
},
  • Related