including javascript in html files

4 replies
  • WEB DESIGN
  • |
As i m developing a website i need to include javascript file for security reasons
but i m not able to write script files by my own as much as i can understand.

please help me to pass this situation
#files #html #including #javascript
  • Profile picture of the author sponsorlist
    If you want to include javascript file(.js) to some html file, put this kind of code somewhere between <head></head> tags in the html file:
    <script type="text/javascript" src="ht tp://site.com/path/script.js"></script>
    If you want to put javascript code directly inside html file, then use something like this:
    <script type="text/javascript">
    <!--
    document.write('<b>Hello World</b>');
    // -->
    </script>
    {{ DiscussionBoard.errors[2810233].message }}
  • Profile picture of the author alex.caronet
    You may show code here to get advice
    {{ DiscussionBoard.errors[2810271].message }}
    • Profile picture of the author alexandrupaul
      anyway you do it (include it in html file directly with <script ... > or referring to the file) i don't think you can hide the script from the client because javascript gets executed on client machine.

      if you mean by security that you wouldn't like a visitor to copy your javascript script.
      {{ DiscussionBoard.errors[2811830].message }}
  • Profile picture of the author millerb7
    You're REALLY better off putting it into it's own file. It really jumbles up the html when it's in there. Also, if you write XHTML instead of HTML (which you should, as it's better)... then the simple <script> will NOT work... it's much more complicated.

    Something like...

    <script type="text/javascript"><!--//--><![CDATA[//><!-- etc etc etc
    {{ DiscussionBoard.errors[2812039].message }}

Trending Topics