Skip to content
Advertisement

‘showPDF’ is declared but its value is never read

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

Advertisement

Answer

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);
},
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement