Empty <SCRIPT> Tags Required?

  • Thread starter Thread starter Jeffrey T.
  • Start date Start date
J

Jeffrey T.

I had some JavaScript functions defined in the <SCRIPT> section at the top
of an aspx page (tested fine there).

I then moved the JavaScript functions to their own separate file and then
referenced that file in the <HEAD> section of the aspx page.

I then removed the <SCRIPT> section from the aspx page, and the JavaScript
stopped working (it was getting called, but some functionality wasn't
working). I verified the path and file name to the new JavaScript file.
Ultimately I found that everything works fine as long as a <SCRIPT> section
exists in the <HEAD> of the aspx page. The script section can be completely
empty and everything will work just fine. Remove it and some of the
JavaScript functionality disappears.

Is this normal, or am I missing something. The following is the entire HEAD
section of the aspx file in question.

<HEAD>
<TITLE>Site Organizer</TITLE>
<link rel="stylesheet" href="css/admin.css" type="text/css">
<script type="text/javascript" src="scripts/treelogic.js">


<SCRIPT type="text/javascript">

</SCRIPT>


</HEAD>
 
The "empty" script tag is serving a purpose. Don't you see that it is
referencing the file called treelogic.js, where there is more JavaScript
that is now available because of the reference to it?
 
And, you've nested your script tags improperly. It should be:

<HEAD>
<TITLE>Site Organizer</TITLE>
<link rel="stylesheet" href="css/admin.css" type="text/css">
<script type="text/javascript" src="scripts/treelogic.js"></script>
</HEAD>
 
Back
Top