change document.body.appendChild(canvas); to document.getElementById('headerId').appendChild(canvas);