IE Error: cannot open the internet site, operation aborted

It’s error arises then JavaScript trying to add elements in existing DOM-structure.
Check this example:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Internet Explorer: Operation Aborted. Sample error.</title>
</head>
<body>
<table>
<script>
document.body.appendChild(document.createElement('div'))
</script>
</table>
</body>
</html>

There are two ways to avoid this:

  1. Run script in windows.onload function:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
     <html>
     <head>
       <title>Internet Explorer: Operation Aborted. Sample solution.</title>
       </head>    <body>
       <ul>
          <script>
           window.onload = function(){
            document.body.appendChild(document.createElement('div'))
          }
      </script>
      </ul>
     </body>
     </html>
  2. Or add to javascript tag parameter defer=”defer”:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html>
     <head>
      <title>Internet Explorer: Operation Aborted. Sample error.</title>
     </head>
     <body>
      <table>
        <script defer="defer">
         document.body.appendChild(document.createElement('div'))
          </script>
        </table>
      </body>
     </html>

Leave a Reply