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 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2009
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    load javascript after dom load

    Hi guys,

    I am trying to insert the following call into my page;

    Code:
          <script type="text/javascript" defer="true">
    $('#query').autocomplete({
        serviceUrl:'service/autocomplete.ashx',
        minChars:1,
        delimiter: /(,|;)\s*/, // regex or character
        maxHeight:400,
        width:250,
        deferRequestBy: 0, //miliseconds
        params: { country:'Yes' }, //aditional parameters
        // local autosugest options:
        lookup: ['January', 'February', 'March', 'April', 'May'] //local lookup values
      });
    </script>

    It works fine in all browsers except ie(6,7,8)
    Code:
    Internet Explorer can not open website. Operation Aborted.
    I understand it is caused by the jquery autocomplete function loading before the page / DOM has fully loaded.

    I tried adding Defer="true" to the script however this doesn't seem to work.

    Could someone please tell me what i must add to the script so that it loads after the dom has fully loaded?

    Thanks guys

    George

  • #2
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    have you tried surrounding that with

    Code:
    $(document).ready(function() {
    //your js
    });

  • Users who have thanked seco for this post:

    mrkorg (10-24-2009)

  • #3
    New Coder
    Join Date
    Oct 2009
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    thanks guys i will give it a try now....

    Ill let you know waht happens

  • #4
    New Coder
    Join Date
    Oct 2009
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    SECO YOU LEGEND!!!!!!!

    Thanks mate its working perfectly

    Much Appreciated....


  •  

    Posting Permissions

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