wordpress: add modal box manually to header.php
<p>i want to add the following code to my wordpress header.php to open up a modal box, when I click on a button (in this case i can not usw any plugin) therefore i wan to do it like on this page:</p>

<p><a href="http://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal" rel="nofollow noreferrer">http://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal</a></p>

<p><strong>CSS</strong></p>

<pre><code>/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    padding-top: 100px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
}

/* The Close Button */
.close {
    color: #aaaaaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}
</code></pre>

<p><strong>HTML</strong></p>

<pre><code>&lt;!-- Trigger/Open The Modal --&gt;
&lt;button id="myBtn"&gt;Open Modal&lt;/button&gt;

&lt;!-- The Modal --&gt;
&lt;div id="myModal" class="modal"&gt;

  &lt;!-- Modal content --&gt;
  &lt;div class="modal-content"&gt;
    &lt;span class="close"&gt;×&lt;/span&gt;
    &lt;p&gt;Some text in the Modal..&lt;/p&gt;
  &lt;/div&gt;

&lt;/div&gt;
</code></pre>

<p><strong>JS</strong></p>

<pre><code>// Get the modal
var modal = document.getElementById('myModal');

// Get the button that opens the modal
var btn = document.getElementById("myBtn");

// Get the &lt;span&gt; element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks the button, open the modal 
btn.onclick = function() {
    modal.style.display = "block";
}

// When the user clicks on &lt;span&gt; (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
}
</code></pre>

<p>but the problem is i only get the error:</p>

<p>"type error: btn is null</p>

<p>but my button element was implemented directly at the body, so why it could be not found???</p>

<p>thanks for any help or hints!</p>

<p>greetings</p>

<p>Alex</p>