SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict aniltc's Avatar
    Join Date
    Nov 2006
    Location
    INDIA
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Javascript source path ................

    hi all

    i have an index.html as below

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
         <title>Rotating Banner</title>
         <script src="script.js" language= "javascript" type="text/javascript"> </script>
    </head>
    <body bgcolor="#FFFFFF">
         <div align="center">
            <img src="images/images1.JPG"  width="400" height="475" id="adBanner"  alt="Ad
     Banner" />
         </div>
    </body>
    </html>
    and script.js as

    HTML Code:
    <script>
    window.onload = rotate;
    
    var adImages = new Array("images/images1.JPG", "images/images2.JPG","images/images3.JPG");
    var thisAd = 0;
    
    function rotate() {
         thisAd++;
         if (thisAd == adImages.length) {
            thisAd = 0;
         }
         document.getElementById("adBanner").src = adImages[thisAd];
    
         setTimeout("rotate()", 3 * 1000);
    }
    
    </script>
    so when i am trying to acess the index.html,my javascript not working

    This script is for ratating an image

    if iam placing the js code after htm tag its working fine.But when i am stored it as a seprate js file javascript not loading...................

    plz help

  2. #2
    SitePoint Addict
    Join Date
    Oct 2006
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what directory contains the script.js file? I hope its the same directory as the index.html file. If not, that's your problem.

  3. #3
    SitePoint Addict aniltc's Avatar
    Join Date
    Nov 2006
    Location
    INDIA
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Hi all

    I solved the problem
    no need of giving <script> </script> in script.js

    Thanks & Regards

  4. #4
    SitePoint Member jojyphp's Avatar
    Join Date
    Jan 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Be carefull!!!

    Just Remove <script> </script> From JS File
    Last edited by jojyphp; Jan 4, 2007 at 23:53.
    Thanks&Regards
    [B]JPJ -


Bookmarks

Posting Permissions

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