Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I arrange my js file to be inside a file rather than in webpage

Status
Not open for further replies.

manou

Technical User
Joined
Sep 9, 2000
Messages
3
Location
CA
Hello;
I have a js code that I don't want to put it in my web page, I want to have it in a .js file and then call it from web page, but there is a code (last code) that I am not sure if it should be inside the file or in the web page, appreciate your help, here is the code:

Code:
<!-- Start of code for [URL unfurl="true"]http://www.mywebsite.com[/URL] -->
<script type="text/javascript">

var nsSiteId=1;
var nsTrackPath='[URL unfurl="true"]http://www.mywebsite.com/statistic/test/default.html?';[/URL]
var nsTrackMode='default';
var nsCode=1;

</script>
<script type="text/javascript" src="[URL unfurl="true"]http://www.mywebsite.com.com/statistic/track.js"></script>[/URL]
<!-- End of code -->

is it OK to have the js file like the following:

Code:
var nsSiteId=1;
var nsTrackPath='[URL unfurl="true"]http://www.mywebsite.com/statistic/test/default.html?';[/URL]
var nsTrackMode='default';
var nsCode=1;

then,
if I call this "mycode.js, could I add the following codes in my web page to call it:

Code:
<script language="Javascript" type="text/javascript"src="[URL unfurl="true"]http://www.mywebsite.com/js-folder/mycode.js"></script>[/URL]

<script type="text/javascript" src="[URL unfurl="true"]http://www.mywebsite.com.com/statistic/track.js"></script>[/URL]

could these be right?
or the last code must be inside file, if so how to write it.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top