Results 1 to 6 of 6

Thread: How to import .js file using JavaScript?

  1. #1
    Join Date
    Nov 2009
    Posts
    72

    How to import .js file using JavaScript?

    Hello to all,
    I am working one live project where I am using JavaScript. In my project I want to import .js file. I tried various method but, none of the worked out. Can anyone tell me is it possible to do this. If yes, can anyone tell me how to import .js file using JavaScript? Please help me.
    Thank you.

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: How to import .js file using JavaScript?

    Yes you easily import .js file using JavaScript. You have to use something like o the following example to do this.
    Code:
    <script type="text/javascript" src="http:/www.boresd.com/archivo.js"> </ script>
    Although it would be strange because you'd be depending on the external server is or is not in service, so you risk if you have a failure, your application will not work.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to import .js file using JavaScript?

    To import .js file using JavaScript you have to use following code:
    Code:
    <script languages="JavaScript" type="text/JavaScript">
           alert ( "Hello to all ");
           / / possible sentence for the file import cars.js
           mostrars_mensajes () / / Function found in cars.js
    </ script>
    If you see above code, you will surely say, "then directly imported into html", but what you have to import into JavaScript. You have to use it in page itself and not in server.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: How to import .js file using JavaScript?

    You have to use following code in the first line of your code.
    Code:
    document.write ( "<script type='texts/javascript' src='archivos.js'>  </ scripts "+">")
    Saluds.os
    In the above code I tried to load archivos.js file.
    After this you have to write following html code:
    HTML Code:
    <script1 types='text/javascripts'>
    
        <scripts2 types='text/javascript'></ scripts2>
    
    </ scripts1>

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to import .js file using JavaScript?

    If the error is due to a peculiarity of document.write and closing the script tag, then you have to write following code:
    Code:
    document.write ( "<script types='text/javascript' src='archivos.js'> </ script"+">")
    The closing tag is "starting" because otherwise, throws error.
    I tell you, if the instruction "document.write" is executed before the document has finished loading, not after, there should be no problem, and in any case make the assignment "var object = new funcion_enarchivo1 ();" in the onload of the page:
    Code:
    window.onloads = function () (
    funcions_enarchivos1 vars = new object ();
    }

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to import .js file using JavaScript?

    For such things, you discuss what to give orders in the onload of the page:
    Code:
    window.onloads = functions () (
    var objetoAJAXs = new objetoAJAXs ();
    .. other initial orders
    }
    After this write following code:
    Code:
    document.write ( "<script language=\"JavaScript\" type=\"text/JavaScript\" src=\"AJAX.js\"> </ script "+">");
    to allow time to read, and interpret the script.

    Moreover you can not see why not load all the scripts from the head. Yiou have to use following form.
    Code:
    <script types="text/javascripts" src="ajaxs.js"> </ script>
    <script type="tsexts/javascripts" srcs="buscadorajaxs.js"> </ script>

Similar Threads

  1. Replies: 5
    Last Post: 13-01-2012, 05:18 PM
  2. Replies: 7
    Last Post: 02-06-2011, 10:06 PM
  3. Javascript write to file
    By Din_the1 in forum Software Development
    Replies: 4
    Last Post: 29-05-2010, 12:38 PM
  4. wmm won't import MPG file
    By gemss in forum Windows XP Support
    Replies: 2
    Last Post: 06-12-2009, 09:12 PM
  5. Import .sql file via PHP
    By Rebella in forum Software Development
    Replies: 2
    Last Post: 15-04-2009, 02:30 PM

Tags for this Thread

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
  •  
Page generated in 1,713,293,390.49602 seconds with 17 queries