Login | Iscriviti | FAQ
Anonymous

Put an external javascript script in a different file

+ Rispondi al messaggio

3 messaggi Pagina 1 di 1


Put an external javascript script in a different file

da Jono » sab ott 27, 2012 7:54 pm

I need help inserting my javascript script into a different file in the same directory. Please can you tell me a code to use instead of putting the whole script in one file with all my other content.
Avatar utente

Jono

  • Messaggi: 45
  • Iscritto il: mer ott 24, 2012 1:10 pm

Re: Put an external javascript script in a different file

da PatoKirui » dom ott 28, 2012 10:01 am

The best way is to create another file lets say "myjavascript.js" where you would put your javascript code for example
document.write('helo world. This is my javascript practice!');

after this save your code but remember its file extension (.js).
Then go back to your html file and in your head section, call your javascript file by its correct name i.e
<html><head>
<link rel="stylesheet"
type="text/javascript"
href ="myjavascript.js" />
</head>
try it with your text editor and if you still have difficulties in this share it again.
Avatar utente

PatoKirui

  • Messaggi: 46
  • Iscritto il: dom giu 03, 2012 12:24 pm
  • Località: Eldoret, Rift Valley, Kenya.

Re: Put an external javascript script in a different file

da XainPro » lun ott 29, 2012 5:15 pm

in this lesson
http://html.net/tutorials/javascript/lesson2.php

read the portion of
Insert JavaScript in a separate file
Avatar utente

XainPro

  • Messaggi: 3933
  • Iscritto il: ven feb 17, 2012 8:10 pm


+ Rispondi al messaggio

Pagina 1 di 1