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 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    externalising js code

    I am creating a travel website and have a ton of javascript that I need to load in my website. for some reason when I use

    <SCRIPT language=javascript
    src="java_script/myfile.js"></SCRIPT>

    my site gives me a bunch of errors. travel_grove.php is my general layout. I pull in the center piece as needed using php. One such center piece is set_form.html, which is basically a reworked search box from another travel site .

    well anyways I would like to post the two files,if anyone can extract the javascript code from the two files and repost them here along with a brief explanation about how you did it so I can actually learn something, that would be more than awesome.... I am such a rookie, dang....


    Well thanks anyways,

    Peter
    Attached Files Attached Files

  • #2
    New Coder
    Join Date
    Feb 2004
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When you externalise js code, you should remove the "<!--" (comment-tags)

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    why remove the comment tags?

    ...

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    ... because <!-- comments are HTML comments. As long as your code is placed within the HTML page, it will be ok, but when you move the code inside an external, you have to remove all the HTML comments and, of course, the marks <script></script>

    If you want to insert comments inside the javascript code, use

    //insert comment here
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New Coder
    Join Date
    Mar 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    one more thing

    great thank you very much... this works very nicely...

    On my travel site I use a simple php code to load the search pieces. Every search piece has tons of Javascript coding and I need to export them all.
    My question is:

    can I import the HTML page with the:

    <SCRIPT language=javascript
    src="java_script/myjsfiles.js"></SCRIPT>

    code inside of it?or would I need to have some js statement on my main page saying that if hotel page is called then call hotel.js if car.html is called then call car.js etc.

    Or can i just put down on my car.html

    <SCRIPT language=javascript
    src="java_script/car.js"></SCRIPT> ... etc.



    Again thanks for your help.

    Peter

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I don't quite understand.. you want to import a HTML page using javascript? can u detail, please?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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