Results 1 to 5 of 5

Thread: External Javascript

  1. #1
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question External Javascript

    I was wondering, when you have a javascript that calls for certain part to be placed in HEAD & other part in BODY can I have this script converted into external file?
    This would make it easier for certain editing asa opposed to hunting specific section through out the whole page of code.

    Thanx
    Mark

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    You can simply take everything between the <script> and </script> tags and put it into "script.js", refer to that in the opening tag (<script src=....)

    And you're done. At least this is the general answer... specifics might be slightly more complex)

    The body tag is part of the html and is needed.

    All an external .js file is doing is saving you having to have that code at the top of your page... not changing the html.

    Just use the body tag like normal, but you can have the .js external and it should be fine.


    Make sense?
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Excellent
    I will give it a shot
    thank you very much

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

    Default

    Make sure there are no HTML tags, such as <script></script> or <!-- --> in the JS file.
    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!

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    Ah, yeah. Good point there.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •