Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts

    How to stop double booting?

    Hey I am almost done with my API boot system and with the way I am calling new files it seems to double boot how can I stop this from happening as the page fully loads and that but the loader shown in the IE tab doesn't stop and it says '1 item remaining' and that never goes, both stay until you click anywhere on the document, so I was wondering if there is a way to stop this.

    My code to call the js document in the file 'boot.js'.
    Code:
    var o = 'http://www.example.com/file.js';
    document.write("<script src=\""+o+"\" type=\"text\/javascript\"><\/scr"+"ipt>");
    And in index.html I have this script tag
    Code:
    <script type="text/javascript" src="http://www.example.com/boot.js"></script>
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,995
    Thanks
    15
    Thanked 233 Times in 233 Posts
    This is just a shot in the dark, but try following the document.write line in boot.js with this:

    document.close();

  • #3
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    I'll give it a go but wouldn't that basicly close the file right after opening it which would result in the codes inside the included file being useless and unusable in boot.js

    For example:

    - file.js
    Code:
    // Creating printString function
    function printString(o) {
      alert(o);
    }
    - boot.js
    Code:
    // Setting the include URL
    var o = 'http://www.example.com/file.js';
    
    // Including the set URL
    document.write("<script src=\""+o+"\" type=\"text\/javascript\"><\/scr"+"ipt>");
    
    // Close include -- Unsure!
    document.close();
    
    // Using included function inside pickString
    function pickString(o) {
      if(o == 1) {
        printString('You chose string 1');
      } else if(o == 2) {
        printString('You chose string 2');
      }
    }
    - index.html
    Code:
    <!DOCTYPE html>
    <html>
    <head>
      <title>Untitled Document</title>
      <script type="text/javascript" src="http://www.example.com/boot.js"></script>
      <script type="text/javascript">
      //<![CDATA[
      window.onload = (function() {
        // Setting btn1 and btn2 as ID objects
        var btn1 = document.getElementById('btn1'),
            btn2 = document.getElementById('btn2');
    
        // Checking and using btn1 and btn2 to pick a string
        if(btn1) { btn1.onclick = (function(){pickString(1);}); }
        if(btn2) { btn2.onclick = (function(){pickString(2);}); }
      });
      //]]>
      </script>
    </head>
    <body>
      <input type="button" value="Alert 1" id="btn1" />
      <input type="button" value="Alert 2" id="btn2" />
    </body>
    </html>
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •