JavaScript: Set <object data="">

by MythOfEchelon

HTML

<!DOCTYPE html> <!-- This is just my HTML5-valid template. Make sure you set this up correctly for your personal needs -->

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        
        <script>
            document.onreadystatechange = function(){
                if (document.readyState === "complete"){
                    /* 
                       Page is fully loaded and ready for interaction.
                       Using this method circumvents issues caused by attempted interaction with uninitialized objects.
                    */
                    
                    set_objectData();
                }
            }
            
            function set_objectData(){
                var pdfDoc_Data = "test_content.pdf";
                var pdfDoc_Element = document.getElementById("pdfDoc");
                pdfDoc_Element.setAttribute("data", pdfDoc_Data);
            }
        </script>
    </head>
    
    <body>
        <object id="pdfDoc" type="application/pdf" height="100%" width="100%" data=""></object>
    </body>
</html>