title: Why am I not able to show or hide in Internet Explorer 8, and how I can fix the problem?
body: <p>I have written JavaScript code to show and hide the div. But I got stuck when it is not working in Internet Explorer 8. It is working smoothly in other browsers, like Opera, Firefox etc.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Javascript Show Hide Div Visibility&lt;/title&gt;
  
          &lt;style type="text/css"&gt;
          &lt;/style&gt;
  
          &lt;script language="javascript" type="text/javascript"&gt;
          function showHideDiv()
          {
              var divstyle = new String();
              divstyle = document.getElementById("div1").style.visibility;
              if(divstyle.toLowerCase()=="visible" || divstyle == "")
              {
                  document.getElementById("div1").style.visibility = "hidden";
              }
              else
              {
                  document.getElementById("div1").style.visibility = "visible";
              }
          }
          &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;div id="div1" class="divStyle"&gt;
              &lt;object width="300" height="300"&gt;
                  &lt;param name="movie" value="http://www.youtube.com/v/7_6B6vwE83U"&gt;
                  &lt;/param&gt;
                  &lt;embed src="http://www.youtube.com/v/7_6B6vwE83U"
                         type="application/x-shockwave-flash"
                         width="300"
                         height="300"&gt;
                  &lt;/embed&gt;
              &lt;/object&gt;
          &lt;/div&gt;
  
          &lt;center&gt;
               &lt;div onclick="showHideDiv()"&gt;Click Me For show hide &lt;div&gt;
          &lt;/center&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>