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
    Regular Coder
    Join Date
    Feb 2007
    Posts
    217
    Thanks
    25
    Thanked 1 Time in 1 Post

    calling function from external js fails

    On my site I'm using an external (big) javascript file, in this external file there is a function with the following line in it:

    Code:
    					
    function showslide(){
    return(currentSlide);
    }
    In my main html file the external javascript file is loaded within the head section. This external file does a lot of other stuff besides returning a number.

    Now here is my problem..
    Somewhere in my html file I need to call the showslide function. I tried doing that with this:

    Code:
    <script language ="Javascript" src="upload/3weg_slider.js"> 
    document.write(showslide()); 
    </script>
    But it doesn't return anything, when I place an alert line within the function it doesn't show up either. What am I doing wrong here?

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    974
    Thanks
    19
    Thanked 212 Times in 210 Posts

    Smile

    change ....

    Code:
    <script language ="Javascript" src="upload/3weg_slider.js"> 
    document.write(showslide()); 
    </script>
    to this ....

    Code:
    <script language ="Javascript" src="upload/3weg_slider.js"> 
    document.write(showslide()); 
    </script>
    
    <script language ="Javascript" > 
    document.write(showslide()); 
    </script>
    then come back and ask more questions

  • #3
    Regular Coder
    Join Date
    Feb 2007
    Posts
    217
    Thanks
    25
    Thanked 1 Time in 1 Post
    I've tried that, but it still doesn't give me any result :S


  •  

    Posting Permissions

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