title: popup on body onload is not working on IE?
body: <p>I am using JavaScript to popup a window over current page on specific condition. It works fine with <strong><em>firefox and chrome</em></strong> but <em>not in IE</em>.</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
            function toggle(div_id) {
                var el = document.getElementById(div_id);
                if ( el.style.display == 'none' ) {el.style.display = 'block';}
                else {el.style.display = 'none';}
            }
            function blanket_size(popUpDivVar) {
                if (typeof window.innerWidth != 'undefined') {
                    viewportheight = window.innerHeight;
                } else {
                    viewportheight = document.documentElement.clientHeight;
                }
                if ((viewportheight &gt; document.body.parentNode.scrollHeight)
  &amp;&amp; (viewportheight &gt;
   document.body.parentNode.clientHeight))
   {
                    blanket_height = viewportheight;
                } else {
                    if (document.body.parentNode.clientHeight
    document.body.parentNode.scrollHeight)
   {
                        blanket_height = document.body.parentNode.clientHeight;
                    } else {
                        blanket_height = document.body.parentNode.scrollHeight;
                    }
                }
                var blanket = document.getElementById('blanket');
                blanket.style.height = blanket_height + 'px';
                var popUpDiv = document.getElementById(popUpDivVar);
                popUpDiv_height=blanket_height/2-150;//150
   is half popup's height
                popUpDiv.style.top = popUpDiv_height + 'px';
            }
           function window_pos(popUpDivVar) {
                if (typeof window.innerWidth != 'undefined') {
                    viewportwidth = window.innerHeight;
                } else {
                    viewportwidth = document.documentElement.clientHeight;
                }
                if ((viewportwidth &gt; document.body.parentNode.scrollWidth)
   &amp;&amp; (viewportwidth &gt;
   document.body.parentNode.clientWidth))
   {
                    window_width = viewportwidth;
                } else {
                    if (document.body.parentNode.clientWidth
    document.body.parentNode.scrollWidth)
   {
                        window_width = document.body.parentNode.clientWidth;
                    } else {
                        window_width = document.body.parentNode.scrollWidth;
                    }
                }
                var popUpDiv = document.getElementById(popUpDivVar);
                window_width=window_width/2-150;//150
   is half popup's width
                popUpDiv.style.left = window_width + 'px';
            }
            function popup(windowname) {
                blanket_size(windowname);
                window_pos(windowname);
                toggle('blanket');
                toggle(windowname);
            }
           &lt;/script&gt;
  
  
          &lt;?php if(  $_SESSION['ses']['count'] &lt; 6 &amp;&amp; !isset($_SESSION['ses']['cancelBack']) ){ ?&gt;
  
      &lt;body onload=" popup('popUpDiv'); "&gt;
          &lt;div id="blanket" style="display:none;"&gt;&lt;/div&gt;
      &lt;div id="popUpDiv" style="display:none; opacity:100;"&gt;
  
      &lt;div id="brouse_now"&gt;
          &lt;div class="top_blanck"&gt;
              &lt;div class="cross"&gt;&lt;a href="&lt;?php echo $this-&gt;url(
                                  array('controller' =&gt; 'index', 'action' =&gt; 'cancel'),
                                  'default',
                                  true) ?&gt;"&gt;&lt;/a&gt;
              &lt;/div&gt;
          &lt;/div&gt;
           &lt;div class="bot_blanck"&gt;
               &lt;div class="top_text_gree"&gt;&lt;?php echo ($this-&gt;user[0]['name']); ?&gt;, thanks for coming back !&lt;/div&gt;
           &lt;/div&gt;
           &lt;div class="bot_blanck"&gt;
           &lt;p&gt; Search &lt;/p&gt;
           &lt;/div&gt;
  
           &lt;div class="browseget_btn"&gt;
               &lt;a href="&lt;?php echo $this-&gt;url(
                                  array('controller' =&gt; 'index', 'action' =&gt; 'search'),
                                  'default',
                                  true) ?&gt;" onclick="popup('popUpDiv')"&gt;
                   &lt;img src="&lt;?php echo $this-&gt;baseUrl(); ?&gt;/images/button/browseand_getfree.png" alt="" /&gt;
               &lt;/a&gt;
           &lt;/div&gt;
  
           &lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  
      &lt;?php } ?&gt;
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>It is also running well in the onclick() event but creating problem with onload() event.</p>
  
  <p>What may be the possible reasons, please help....</p>
  
  <p>Thanks In Advance.....</p>