Results 1 to 2 of 2

Thread: Help with using external script files

  1. #1
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Help with using external script files

    John has asked me to post this instead of contacting him directly, so here is my initial question and his response. I would appreciate it if someone could answer the question about imbedding the call within an "if" statement, though.

    ********************* Question *****************************
    Hi John.

    I've read your postings about using external script files and while I
    believe that I have met all of the requirements you specified, I can't
    get my external file to work. I would like to have this script included
    in about half of my pages, which is why I want to use an external file.
    I've attached it in case there's something unique about it. The call
    line is:

    <script src="ScrollArrows.js" type="text/javascript"></script>

    and, yes, it's in the same folder as the pages that will call it.

    Can you help?

    Also, once it's working, can the call be put inside an "if" statement?
    What I really want to do in only have the script execute if the viewer's
    viewing area is less than a particular size.

    ********************* John's Response ***********************
    you cannot have this:

    <div id="staticbuttons2" style="position:absolute;">
    <a href="javascript:" onmouseover="myspeed=thespeed" onmouseout="myspeed=0"><img
    src="hold/arrows_dn.gif" border="0"></a></div>
    <div id="staticbuttons" style="position:absolute;">
    <a href="javascript:" onmouseover="myspeed=-thespeed" onmouseout="myspeed=0"><img
    src="hold/arrows_up.gif" border="0"></a><br>
    </div>

    <script>

    or this:

    </script>

    in an external script file. You can just get rid of the </script> and replace the top part (including the <script>) with:

    document.write('<div id="staticbuttons2" style="position:absolute;">')
    document.write('<a href="javascript:" onmouseover="myspeed=thespeed" onmouseout="myspeed=0">')
    document.write('<img src="hold/arrows_dn.gif" border="0"></a></div>')
    document.write('<div id="staticbuttons" style="position:absolute;">')
    document.write('<a href="javascript:" onmouseover="myspeed=-thespeed" onmouseout="myspeed=0">')
    document.write('<img src="hold/arrows_up.gif" border="0"></a><br></div>')

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    There are ways of conditionally linking in a script, such as:
    Code:
    if(condition) document.write('<script type="text/javascript" src="test.js"><\/script>');
    However, to help other than that, I would have to see your page.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •