EDIT: Sorry, I should have been more clear. My webpage needs to be XHTML compliant.
I use a hosted blogging platform, and there's no way for me to host a JavaScript file on it. We normally reference JavaScript file on a web page like this:
<script type='text/javascript' src='http://example.com/js/mycode.js'></script>
The question is, can I directly reference code in the web page, instead of the file? If so, how do I do that?
Just paste the JavaScript code in the file between
<script>
tags?<script type='text/javascript'> PASTE THE CODE FROM THE JS FILE HERE </script>
OR like this?
<script type='text/javascript'> //<![CDATA[ PASTE THE CODE FROM THE JS FILE HERE //]]> </script>
Which of the above two methods is correct? If not, is there a better way to do it?
Also, can a text (.txt) file be referenced inside a script tag, like this?
<script type='text/javascript' src='http://example.com/js/mycode.txt'></script>
or will there be any issues if I do it like this?
Looking for a knowledgeable answer.