1

I am getting the following error:

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

I have the problem with Stickyfill source (https://github.com/wilddeer/stickyfill)

I have tried more versions I still get the same error. My JavaScript source looks like this:

var a = document.getElementById('left');
Stickyfill.add(a);

Why am I getting this error, how can I fix it?

EDIT: This is my html page:

    <!DOCTYPE html>
<html>
    <head>
        <title></title>
        <link rel="stylesheet" type="text/css" href="css-home.css">
        <script type="text/javascript" src="stickyfill.js"></script>
        <script type="text/javascript" src="js-home.js"></script>

    </head>
    <body>

        <div id="container">
            <div id="banner">
                <img src="sigla.jpg">
            </div>
            <div id="container2">
                <div id="left">
                    <nav>
                    <a target="ifr" href="">Home</a>
                    <a target="ifr" href="">Istoric</a>
                    <a target="ifr" href="echipa.html">Echipa</a>
                    <a target="ifr" href="">Galerie</a>
                    </nav>
                </div>
                <div id="right">

                    <iframe name="ifr" src="echipa.html" frameborder="0" ></iframe>

                </div>
            </div>
            <div id="footer">
                <p>CS MIOVENI</p>
            </div>
        </div>
    </body>

</html>

LATER EDIT: i have solved the problem using window.onload for my javascript file

1 Answers1

0

Can you confirm that:

var a = document.getElementById('left');

actually returns an Element, before you pass it to Stickyfill.add(a)? Either stepping through with debugger or logging e.g;

var a = document.getElementById('left');
// Is an element returned?
console.log(a instanceof Element);
Stickyfill.add(a);
Bardy
  • 2,100
  • 1
  • 13
  • 11