Results 1 to 8 of 8

Thread: Storing the Ultimate Fading Slideshow in a separate file

  1. #1
    Join Date
    May 2007
    Location
    Des Moines, IA
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Storing the Ultimate Fading Slideshow in a separate file

    I am trying to put the Ultimate Fade-in slideshow (v1.5) into a different .js file so I don't have to have all that code in the head of my site, also so I can more easily use it on several pages. And I am not having any luck. I am new at this and have done my best to try several things. Also I am using another script for a menu, so do I have to identify them differently so that they work and if so how do I do that.

    Thanks for who ever helps the newbee

  2. #2
    Join Date
    Feb 2007
    Posts
    293
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Select everything from the javascript code but not the <script type="text/javascript"> at the top or the </script> at the bottom.
    Copy and paste into a file called fadin.js

    Then in the head of your document, delete the javascript code (including the script open and close tags) and replace it with a link to your external script:

    <script type="text/javascript" src="fadin.js">
    /***********************************************
    * Ultimate Fade-In Slideshow (v1.5): Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
    * Visit DynamicDrive.com for hundreds of original DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
    </script>

    Do the same thing for the second script, giving it a different name, and adding a link to this second js file in the head of your document.

    The above link assumes you've put the js files in the same directory. If you put them in a different directory, you would need to just put the path to that as your src.

    (Note to John - thanks again - hopefully this is my last edit!)
    Last edited by Veronica; 06-02-2007 at 11:47 PM. Reason: apparent mental block on this one!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Veronica, please don't advise folks to disregard the DD usage policy which, among other things, states that the credit must remain in the source code of the page(s) that use the script.

    Quote Originally Posted by Veronica View Post
    replace it with a link to your external script:

    <script type="text/javascript" src="fadin.js"></script>
    If you do that, you will be in violation of the Dynamic Drive Usage policy. Other than that, the advice is sound. Here is my more verbose set of tips for making a script external (pay particular attention to 'One other thing' at the end):

    Use a text editor to save the script, call it 'file_name.js' where 'file_name' can be any valid file name of your choosing. Substitute the name of your external .js file for some.js in the below:

    HTML Code:
    <script src="some.js" type="text/javascript"></script>
    Common problems arise when:

    1 ) The script file is not in the directory specified. In the above example it must be in the same directory as the page(s) that use it. Below, it can be in the scripts directory off of the root of a domain:

    HTML Code:
    <script src="http://www.somedomain.com/scripts/some.js" type="text/javascript"></script>
    2 ) Opening, closing and/or 'hiding' tags are left in the external file. This means that you must strip:
    Code:
    <script>
    <!--
    and
    Code:
    //-->
    </script>
    and any of their many variations from the beginning and end of the external file.

    3 ) The external call (<script src="some.js" type="text/javascript"></script>) is not inserted into the page at the correct spot. The external call must be inserted at the same place on the page where the script was/would have been.

    4 ) Paths to other files (if) used by the script are no longer valid due to its location. This is only a problem if the external script is kept in a different directory than the page it was working on when it was an internal script. To correct this, use absolute paths inside the script. Absolute path examples:

    Code:
    http://www.somedomain.com/images/button.gif
    
    http://www.somedomain.com/~mysitename/index.html
    5 ) Inappropriately combining two or more scripts into one external file. Usually external scripts can be combined if one knows enough about scripting to do so properly. Even then it is possible to overlook something.

    A rule of thumb when testing is, if it won't work on the page, it won't work as an external file either.

    One other thing, if this is a DD script or any script that requires the credit remain for legal use, include the credit in the on page call, ex:

    HTML Code:
    <script src="some.js" type="text/javascript">
    /***********************************************
    * IFrame SSI script II- &#169; Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
    * Visit DynamicDrive.com for hundreds of original DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
    </script>
    Make sure to retain all the 'decorations', as these include begin and end javascript comment delimiters without which the script won't function.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Feb 2007
    Posts
    293
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry! I thought the credit in the js file was the way to do it. Now I know better. I fixed in in the original reply.

    Thanks for correcting that - and also thank for all the help you give people on this site.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Veronica View Post
    Sorry! I thought the credit in the js file was the way to do it. Now I know better. I fixed in in the original reply.

    Thanks for correcting that - and also thank for all the help you give people on this site.
    That's OK, I figured it was just an oversight on your part, as you usually know what you are talking about. Thanks for fixing it (although the credit you featured is from a different script), and Thank You for all the help you provide the folks here in these forums.

    Just to clarify, for this particular script, it should look something like so:

    Code:
    <script src="some.js" type="text/javascript">
    /***********************************************
    * Ultimate Fade-In Slideshow (v1.5):  Dynamic Drive (http://www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/
    </script>
    To photodah,

    Warning: Please include a link to the DD script in question in your post. See this thread for the proper posting format when asking a question.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Aug 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Ultimate Fade in slide show script

    Hi John & Veronica,
    I just tried copying the script into a separate .js file and it diesn't work properly. When the script is embedded it works fine.
    The problem is that the Slide show script is in 2 parts - one in the <head> and one in the <body>. If you call up the entire .js file from the <head> then the <body> part doesn't work properly. When the script is embedded, the <body> part of the script is in a <div> to give it placement and it works OK.
    I have tried putting just the <head> part of the .js file and leaving the <body> part of the script embedded but, of course, when the .js file has run it leaves no variables for the embedded bit to work on.
    I posted the same question earlier today :-

    "I am new to scripts and have been using the ultimate fader script to learn on.
    I have manged to get it to work on my html page with the script imbedded in the code. My next try was to put the script into an external file and get it o work that way. Problem:- the ultimate fader is in effect two scripts - the first is the bit that goes in the <head> and the secon is the bit that goes in the <body> I can run the entire script from a separate .js file but then it is all in the <head> section. If I just run the first part of the script from a separate .js file into the <head> section and leave the second part imbedded in the html file I get errors when i try to run it like fadeshow not declared etc.
    How do I run a two part script from a separate .js file? I tried leaving part of the html that goes between the 2 parts of the script in the .js file but that was a disaster!!
    Any help will be appreciated by a newbie!!
    Peter"

    Kiterson pointed me to your comments - hence this reply,
    Many thanks for any help that either of you can give a poor newbie!!
    Peter

  7. #7
    Join Date
    Aug 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    [QUOTE=jscheuer1;94896]Make sure to retain all the 'decorations', as these include begin and end javascript comment delimiters without which the script won't function.

    John,
    How do you define "decorations" ?
    Peter

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by peebs24 View Post
    Quote Originally Posted by jscheuer1 View Post
    Make sure to retain all the 'decorations', as these include begin and end javascript comment delimiters without which the script won't function.
    John,
    How do you define "decorations" ?
    Peter
    Code:
    <script src="some.js" type="text/javascript">
    /***********************************************
    * Ultimate Fade-In Slideshow (v1.51):  Dynamic Drive (http://www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/
    </script>
    Each comment is different, in the above comment, the only essential decorations are:

    Code:
    <script src="some.js" type="text/javascript">
    /***********************************************
    * Ultimate Fade-In Slideshow (v1.51):  Dynamic Drive (http://www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/
    </script>
    But you may as well keep them all. In any case, it is easier to just say, 'keep all', than to try to explain to novices all the possible ways a comment can appear, and how to avoid changing it in such a way that will mess up the script.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •