Results 1 to 4 of 4

Thread: Calling .js file coding

  1. #1
    Join Date
    Jun 2005
    Location
    Canada
    Posts
    68
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Calling .js file coding

    Hi folks,

    New in here and with jscript.
    I am attempting to call java code from a js file to make a site more SE friendly and need assistance with the coding.
    I have uploaded the .js file to the server and all .htaccess permissions are in place (me thinks)
    I have placed the following in the <head></head>

    "<SCRIPT LANGUAGE="JavaScrïpt" type="text/javascrïpt" src="replace-with-JavaScript-file-name.js"></SCRIPT>"

    which I understand must be done.

    What is it that I put in the body to identify what is going in and where it is going?

    Thanks for your help.

  2. #2
    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

    Code:
    <script src="some.js" type="text/javascript"></script>
    is all you really need. Nothing need go in the body, it depends upon the script and what the script is supposed to do (in most cases, simply refer to instructions that come with the script). If your script originally went in the body of the page, the same above syntax may be used in the body instead of in the head to invoke the script. Another consideration is that once your script is in an external file, it must be stripped of its opening and closing script tags as well as html comment tags (if any) of the sort intended to 'hide it from the browser'.
    - John
    ________________________

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

  3. #3
    Join Date
    Jun 2005
    Location
    Canada
    Posts
    68
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    Code:
    <script src="some.js" type="text/javascript"></script>
    is all you really need. Nothing need go in the body, it depends upon the script and what the script is supposed to do (in most cases, simply refer to instructions that come with the script). If your script originally went in the body of the page, the same above syntax may be used in the body instead of in the head to invoke the script. Another consideration is that once your script is in an external file, it must be stripped of its opening and closing script tags as well as html comment tags (if any) of the sort intended to 'hide it from the browser'.
    Thanks for the info jscheuer. The script is a fairly large scrolling text box wherein the primary script is placed in the location that I want it in and then there is an "external1.htm" sitting on a separate page entirely.
    I have placed the "call-up" tag in the body of the page but it is not working now but when the actual javascript is placed there it is fine.

    So do I need to make the adjustments you have indicated to the "external1.htm" page? Or, do I strip the script that is sitting in the .js file?

    Thanks again for the help. I am sure it won't take too long to get my neophyte head around this.

    Cheers

  4. #4
    Join Date
    Jun 2005
    Location
    Canada
    Posts
    68
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    I guess I should have experimented a wee bit before I asked that last question. Took away the code and hidden code in the .js file and it works like a charm.

    Great help. Thank you!

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
  •