Firefox Javascript, stop script

917 Views Asked by At

Basically, this script checks if the user is running a certain addon, if yes, it shows an alert... the problem is after it shows the alert Firefox's spinning wheel keeps spinning like it's waiting for something. And if I refresh the page the script does not work...

This is the code:

<script language="javascript">
  var isInstalled = false;

  function run_if_true() {
    isInstalled = true;
    document.write("Your addon is installed\n<br>");alert("a");
  }

  function check_installed() {
    if (isInstalled==false) {
      document.write("Not installed"); // You can instead have an alert here
    } else {
      document.write("is installed");
    }
  }
</script>
</head>

<body onload="javascript:check_installed()">
  testing!
  <img src="chrome://fil/content/sd.gif" 
       width="0" 
       height="0" 
       onload="javascript: run_if_true()" 
       style="visibility:hidden">
 </body>
</html>
2

There are 2 best solutions below

1
Lance Roberts On BEST ANSWER

After calling document.write(), you need a document.close().

See this link.

0
Brett Zamir On

The ability to load Chrome URLs has been disabled by Firefox 4--you still want to do this? The spinning, I'd guess might relate to a need for a call to document.close(); (as I see someone else just mentioned)