Zaloguj | Zarejestruj | FAQ
Anonymous

Put an external javascript script in a different file

+ Odpowiedz

Posty: 3 Strona 1 z 1


Put an external javascript script in a different file

przez Jono » So paź 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 użytkownika

Jono

  • Posty: 45
  • Dołączył(a): Śr paź 24, 2012 1:10 pm

Re: Put an external javascript script in a different file

przez PatoKirui » N paź 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 użytkownika

PatoKirui

  • Posty: 46
  • Dołączył(a): N cze 03, 2012 12:24 pm
  • Lokalizacja: Eldoret, Rift Valley, Kenya.

Re: Put an external javascript script in a different file

przez XainPro » Pn paź 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 użytkownika

XainPro

  • Posty: 3933
  • Dołączył(a): Pt lut 17, 2012 8:10 pm


+ Odpowiedz

Strona 1 z 1