Search code examples
javascriptfirefoxfirefox-addondom-eventsthrobber

Firefox Javascript, stop script


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>

Solution

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

    See this link.