Jump to content

JavaScript:Tutorial, Using an External Script

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Introduction:-
Here in this tutorial I will tell you how to use an External JavaScript file, so if you have a chunk of code that will be used in multiple pages, you will have to make one Script and then call it from the pages instead of making the same code over and over again!

Solution:-
Open a Text Editor and paste the following code and save it as <<Name>>.js I named it 'External Script.js', this is just a script that will show the time but here you can insert whatever you want!!


test = new Date()

month = test.getMonth()

month = (month * 1) + 1

day = test.getDate()

year = test.getFullYear()

document.write(" ",month,"/",day,"/",year," ")


And this code in the main HTML file:-


<SCRIPT SRC="External Script.js">

</SCRIPT>


Explanation:-

<SCRIPT SRC="External Script.js">

</SCRIPT>


Here we are just calling the External Script, instead of "External Script.js" make whatever name you named your script!

A Preview:-
None

Conclusion:-
As Always Feedback is welcome and the full source is attached!!

Attached Files



#2
xtraze

xtraze

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 910 posts
I use it already and it help us to keep the code beautiful, perhaps.
And easy to integrate js into sites.

#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

xtraze said:

I use it already and it help us to keep the code beautiful, perhaps.
And easy to integrate js into sites.

Yup I agree! I will keep your source code nice, but that would make it more easy for other users to understand it and copy it! I don't care how nice the source is, the worst the better for my site, so people wont understand it easily, the important is that I understand it!

#4
xtraze

xtraze

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 910 posts
To protect things right-click menu can be disabled and I have seen matters when I see the source of some certain websites, Firefox closes. Exit. in about 5 seconds or less.

#5
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Well the Right-Click menu thing is just stupid I know 1000 ways on how to get round thats! thats just a waste of time!

about the second.. hmm I never saw that , but lol I still can hack it its simple! Show me such website and I will show you its source... It's simple to bypass such thing!

#6
WillB

WillB

    Learning Programmer

  • Members
  • PipPipPip
  • 43 posts

Tcm9669 said:

Well the Right-Click menu thing is just stupid I know 1000 ways on how to get round thats! thats just a waste of time!

about the second.. hmm I never saw that , but lol I still can hack it its simple! Show me such website and I will show you its source... It's simple to bypass such thing!

What about a website that was written in Coldfusion? Or perhaps Flex?
Everything in Life can be solved with an 'If/Else' statement.

Life is like one big try/catch statement, nested within a loop.

-Will

[SIGPIC][/SIGPIC]

#7
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Well that is encrypted not just hidden but nothing is 100% safe!

#8
WillB

WillB

    Learning Programmer

  • Members
  • PipPipPip
  • 43 posts

TheComputerMaster said:

Well that is encrypted not just hidden but nothing is 100% safe!

Indeed!
Everything in Life can be solved with an 'If/Else' statement.

Life is like one big try/catch statement, nested within a loop.

-Will

[SIGPIC][/SIGPIC]

#9
cryptokyle

cryptokyle

    Newbie

  • Members
  • PipPip
  • 11 posts
nice tutorial 5/5.