How to detect if document.write() has taken place in JavaScript?
<p>I want to do something when 2 document.write() statements have successfully occured. I tried the following but it didn't work:</p>

<pre><code>        function loadFields() {
            var load1 = document.write("&lt;input type='text' name='StoreLocation' value='"+storeLocation+"' /&gt;");
            var load2 = document.write("&lt;input type='text' name='couponType' value='"+couponType+"' /&gt;");
        }

        if (loadFields()) {
            alert('both items have loaded.');
        }
</code></pre>

<p>I also tried this and again same result:</p>

<pre><code>        var load1 = document.write("&lt;input type='text' name='StoreLocation' value='"+storeLocation+"' /&gt;");
        var load2 = document.write("&lt;input type='text' name='couponType' value='"+couponType+"' /&gt;");

        if (load1 &amp;&amp; load2) {
            alert('both items have loaded.');
        }
</code></pre>
