lucky
lucky

Reputation: 27

what should be the order of tags .aspx page?

I have a test.aspx page.
The html code is

<script type='text/javascript' language='javascript' src="scripts/test.js"></script>
<script type="text/javascript" language='javascript' src="scripts/abc.js"></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>"test Application"</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
</head> ...

But when I am executing this page, it is throwing the following error.

can't execute code from a freed script.

When I search in google, I got the answer as Meta tag should be after script tag.

Is it recommended to put script tags after meta tag in .aspx page.

Upvotes: 0

Views: 61

Answers (3)

JOJO
JOJO

Reputation: 316

The correct syntax is

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head runat="server">
        <title>"test Application"</title>
           <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
                 <script type='text/javascript' language='javascript' src="scripts/test.js"></script>
                  <script type="text/javascript" language='javascript' src="scripts/abc.js"></script>
    </head>
     <body>
     </body>
   </html>

Or You can put the script tag inside the body after the closing of form tag.

Upvotes: 1

Shay
Shay

Reputation: 1768

meta script title should be inside the head tag. You can also load the scripts in the end of the body to increase page loading performance.

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type='text/javascript' language='javascript' src="scripts/test.js"></script>
<script type="text/javascript" language='javascript' src="scripts/abc.js"></script>
<title>"test Application"</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
</head>
<body>
</body>
</html>

Upvotes: 0

Michael Coxon
Michael Coxon

Reputation: 5510

You should do some reading on basic HTML structure http://www.w3schools.com/html/

Your script tags need to be inside the <HTML> element. Ideally at the end of the body tag...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>test Application</title>
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    </head>
    <body>
        <form id="myForm" runat="server">
            <!-- you html elements -->
        </form>
        <script type='text/javascript' language='javascript' src="scripts/test.js"></script>
        <script type="text/javascript" language='javascript' src="scripts/abc.js"></script>
    </body>
</html>

The doctype is important to get the page to render in standards mode. However with the (almost) release of HTML5 you should be using it as it provides many more elements to take advantage of. Example below..

<!doctype html>
<html lang="en">
    <head runat="server">
        <title>test Application</title>
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
    </head>
    <body>
        <form id="myForm" runat="server">
            <!-- you html elements -->
        </form>
        <script src="scripts/test.js"></script>
        <script src="scripts/abc.js"></script>
    </body>
</html>

Upvotes: 0

Related Questions