External Javascript Function

Discussion in 'JavaScript' started by SFNUM8, Mar 15, 2014.

  1. #1
    This is my first try at javascript, but I can't get my external .js file to work.

    *I have included the .js file and jquery src in my <head>

    *I am calling this function right above my closing </body> tag
    <script type="text/javascript">
    ads();
    </script>

    External File:
    $(function (ads) {

    });


    When I put the actual function on the html page it works, when I try to call the function from the external file it does not. How do I correctly call this function?
    Thanks
     
    Solved! View solution.
    SFNUM8, Mar 15, 2014 IP
  2. #2
    try changing the
    $(function (ads) {
    to
    function ads() {

    Besides - since you're not showing us the file, are you sure you've included the files correctly? Like the jQuery-file before the external .js-file, and that the external .js-file is included correctly?
     
    PoPSiCLe, Mar 15, 2014 IP
  3. SFNUM8

    SFNUM8 Active Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thanks you, there was a mistake on my end. I was using a Dreamweaver template and needed the include line to say <script src="../javascript-fixed-ads.js"></script>
    instead I had it as <script src="/javascript-fixed-ads.js"></script>

    It worked with the $ there and didn't without.

    Thanks for your time
     
    SFNUM8, Mar 15, 2014 IP