Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , , ,

Sponsored Links



How to import .js file using JavaScript?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 08-03-2010
Member
 
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.
Reply With Quote
  #2  
Old 08-03-2010
absolute55's Avatar
Member
 
Join Date: Nov 2005
Posts: 1,238
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.
Reply With Quote
  #3  
Old 08-03-2010
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,299
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.
Reply With Quote
  #4  
Old 08-03-2010
opaper's Avatar
Member
 
Join Date: May 2008
Posts: 2,362
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>
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #5  
Old 08-03-2010
MindSpace's Avatar
Member
 
Join Date: Feb 2008
Posts: 1,832
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 ();
}
Reply With Quote
  #6  
Old 08-03-2010
Modifier's Avatar
Member
 
Join Date: Jan 2008
Posts: 1,502
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>
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to import .js file using JavaScript?"
Thread Thread Starter Forum Replies Last Post
Need help to import a Microsoft Excel file to semicolon delimited text file Roch Windows Software 5 4 Weeks Ago 05:18 PM
How to import registry string value from *.csv file or ini file Aalap Operating Systems 7 02-06-2011 11:06 PM
Javascript write to file Din_the1 Software Development 4 29-05-2010 01:38 PM
wmm won't import MPG file rswc90 Windows XP Support 5 07-12-2009 12:44 AM
Import .sql file via PHP Rebella Software Development 2 15-04-2009 03:30 PM


All times are GMT +5.5. The time now is 11:28 AM.