title: I want to redirect to another page if a condition in javascript is true
body: <p>I am developing a desktop app with Adobe AIR. I want to redirect to another page if internet connection is present, and do nothing if internet connection is not present.</p>
  
  <p>Following is the code I am using for detecting internet connection. The following code displays "Please wait" if internet connection is present, and "Internet connection is unavailable" if internet is not connected.</p>
  
  <p>`</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script&gt;
          function CheckOnlineStatus(msg) {
              var status = document.getElementById("status");
              var condition = navigator.onLine ? "Please wait" : "Internet connection is unavailable"; 
              var state = document.getElementById("state");
              state.innerHTML = condition;
          }
  
          function Pageloaded() {
             CheckOnlineStatus("load");
             document.body.addEventListener("offline", function () {
             CheckOnlineStatus("offline")
             }, false);
             document.body.addEventListener("online", function () {
             CheckOnlineStatus("online")
             }, false);
          }
  
      &lt;/script&gt;
      &lt;style&gt;
          ...&lt;/style&gt;
  &lt;/head&gt;
  &lt;body onload="Pageloaded()"&gt;
      &lt;div id="status"&gt;
          &lt;p id="state"&gt;
          &lt;/p&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;` 
  </code></pre>
  
  <p>Please suggest required additions or changes to redirect to "<a href="http://example.com" rel="nofollow">http://example.com</a>" if <code>navigator.onLine</code> is true.</p>