Google Docs viewer returning 204 responses, no longer working, alternatives?

I run a service that also relies on embedding the Google Doc Viewer and I have also encountered this issue. I could not find any other comparable service (free or otherwise).

I have come up with a ‘hack’ that can help you get away with using the Google Doc Viewer. It does require JQuery though. What I do is keep refreshing the iframe every 2 seconds until it finally loads correctly. I also cover the iframe with a loading gif to hide the constant refreshing. My code:

<style>
.holds-the-iframe {
    background:url(/img/loading.gif) center center no-repeat;
}
</style>

<div class="holds-the-iframe">
      <iframe id="iframeID" name="iframeID" src="https://docs.google.com/viewerng/viewer?url=www.example.com&embedded=true"></iframe>
</div>

<script>
function reloadIFrame() {
    document.getElementById("ifm").src=document.getElementById("iframeID").src;
}

timerId = setInterval("reloadIFrame();", 2000);

$( document ).ready(function() {
    $('#iframeID').on('load', function() {
        clearInterval(timerId);
        console.log("Finally Loaded");
    });
});
</script>

Leave a Comment