C# Web and .js - where and how do I specify the location of the .js file

I have a very basic web site I am deploying (dev site is http://ct1data.utrackit.net) and there are a few functions that control the displaying of sub-information.
For example: on the products page there is a line of code:
<li><a href="javascript:showguide(1);">Introduction &raquo;</a></li>

"showguide" is defined in a file "functions.js" as:
function showguide(id){
      for (x=1;x<=5;x++){
            closeid = "section" + x;
            document.getElementById(closeid).style.display="none";
      }
      openid = "section" + id;
      document.getElementById(openid).style.display="block";
      }

Now the problem is the "showguide" function only works if the file "functions.js" is in the root (i.e. the same folder as the page calling it). I want the .js files to all be in the /scripts folder!

Where in the project (or in the .aspx file) do I tell it the .js file is in /scripts?
Bird757Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Create your "scripts" folder and place your scripts in that folder. In pages which much use the script files, include a line like this for each file that is needed:

<script type="text/javascript" src="scripts/functions.js"></script>

Open in new window


You may need to adjust the path based on the relativity of your page to the "scripts" folder. Be sure NOT to self-close the <script> tag--I don't know why, I just know it was a pain to figure out for me  = )
0
Bird757Author Commented:
Thank you. But something wierd has now happened to the default font?

What I did was add the 2nd line below:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="products.aspx.cs" Inherits="_Default" %>
<script type="text/javascript" src="scripts/functions.js"></script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
... etc

Have I put it in the right place?
0
käµfm³d 👽Commented:
No. That's my fault for not being clearer.

You need to put it somewhere within the <html> tag. Common practice is to put it within the <head> tag, though it should work anywhere within the <html> tag.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

nishant joshiTechnology Development ConsultantCommented:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="products.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="scripts/functions.js"></script>
...
..

..
</head>
...


0
Bird757Author Commented:
Thank you!
0
käµfm³d 👽Commented:
NP. Glad to help  = )
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.