Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

JavaScript:Tutorial, Using an External Script


  • Please log in to reply
8 replies to this topic

#1 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 05 December 2006 - 12:34 PM

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


  • 0

#2 xtraze

xtraze

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 872 posts

Posted 30 December 2006 - 01:12 AM

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

#3 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 30 December 2006 - 03:57 AM

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!
  • 0

#4 xtraze

xtraze

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 872 posts

Posted 03 January 2007 - 07:59 AM

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.
  • 0

#5 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 03 January 2007 - 08:17 AM

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!
  • 0

#6 WillB

WillB

    CC Regular

  • Just Joined
  • PipPipPip
  • 43 posts

Posted 07 September 2007 - 07:03 AM

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?
  • 0

#7 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 08 September 2007 - 02:55 AM

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

#8 WillB

WillB

    CC Regular

  • Just Joined
  • PipPipPip
  • 43 posts

Posted 11 September 2007 - 04:39 AM

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


Indeed!
  • 0

#9 cryptokyle

cryptokyle

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

Posted 04 June 2009 - 11:40 PM

nice tutorial 5/5.
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download