Community Forum

factory.printing sometimes returns undefined

Profile Image 1 Posts 1 Karma
tafandi posted this 13 September 2017

Hi I just started trying this (using the free version)

Using IE's F12 Console, if I check factory.printing sometimes it returns the object, but some other times (in other PC or even other tab) sometimess it just returns undefined.

What am I doing wrong? 

FYI my version is IE11

The code is as simple as this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head></head><body>
<object id="factory" viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="/v3/~f/_inc/client/smsx.8.0.0.56.cab#Version=8,0,0,56"></object>
   
<script>
    function getfactoryprinting() {
      var f = document.getElementById("factory")
      console.log(f.readyState);
      console.log(f.printing);
    }
    
    window.onload = function() { 
      setTimeout(getfactoryprinting, 3000); 
      getfactoryprinting();
    }
    </script>
</body></html>
Profile Image 168 Posts 168 Karma
Jerry posted this 14 September 2017

If this were my code I'd lose window.onload in favor of a <body onload call, and forget the timeout.

 

A body onload event shouldn't be called before a document goes complete anyway.

Post Edited 14 September 2017