Log in

View Full Version : Calling .js file coding



Diversions
06-27-2005, 01:56 PM
Hi folks,

New in here and with jscript.
I am attempting to call java code from a js file to make a site more SE friendly and need assistance with the coding.
I have uploaded the .js file to the server and all .htaccess permissions are in place (me thinks)
I have placed the following in the <head></head>

"<SCRIPT LANGUAGE="JavaScrïpt" type="text/javascrïpt" src="replace-with-JavaScript-file-name.js"></SCRIPT>"

which I understand must be done.

What is it that I put in the body to identify what is going in and where it is going?

Thanks for your help.

jscheuer1
06-27-2005, 04:47 PM
<script src="some.js" type="text/javascript"></script>is all you really need. Nothing need go in the body, it depends upon the script and what the script is supposed to do (in most cases, simply refer to instructions that come with the script). If your script originally went in the body of the page, the same above syntax may be used in the body instead of in the head to invoke the script. Another consideration is that once your script is in an external file, it must be stripped of its opening and closing script tags as well as html comment tags (if any) of the sort intended to 'hide it from the browser'.

Diversions
06-27-2005, 06:35 PM
<script src="some.js" type="text/javascript"></script>is all you really need. Nothing need go in the body, it depends upon the script and what the script is supposed to do (in most cases, simply refer to instructions that come with the script). If your script originally went in the body of the page, the same above syntax may be used in the body instead of in the head to invoke the script. Another consideration is that once your script is in an external file, it must be stripped of its opening and closing script tags as well as html comment tags (if any) of the sort intended to 'hide it from the browser'.

Thanks for the info jscheuer. The script is a fairly large scrolling text box wherein the primary script is placed in the location that I want it in and then there is an "external1.htm" sitting on a separate page entirely.
I have placed the "call-up" tag in the body of the page but it is not working now but when the actual javascript is placed there it is fine.

So do I need to make the adjustments you have indicated to the "external1.htm" page? Or, do I strip the script that is sitting in the .js file?

Thanks again for the help. I am sure it won't take too long to get my neophyte head around this.

Cheers

Diversions
06-27-2005, 06:44 PM
I guess I should have experimented a wee bit before I asked that last question. Took away the code and hidden code in the .js file and it works like a charm.

Great help. Thank you!