JQuery and javascript not runing in the head tag

Discussion in 'ASP General' started by John Morrill, Jun 28, 2010.

  1. John Morrill

    John Morrill Guest

    Greetings!

    When I create a simple page like this!

    <html>
    <head>
    <title>Test</title>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript" />
    <script type="text/javascript">
    alert("From Head");
    </script>
    </head>
    <body>
    <span>Click me!</span>
    <script type="text/javascript">
    alert("From Body");
    </script>
    </body>
    </html>

    Only the second alert is displayed. When I comment out the jquery library as
    shown below, both alerts are shown.

    <html>
    <head>
    <title>Test</title>
    <!--
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript" />
    -->
    <script type="text/javascript">
    alert("From Head");
    </script>
    </head>
    <body>
    <span>Click me!</span>
    <script type="text/javascript">
    alert("From Body");
    </script>
    </body>
    </html>

    The jquery library is the one supply with VS2010. I am sure I am doing
    something obvious wrong, but I can not see it.

    Also, if this is not a forum that Microsoft engineers support, can some
    please let me know. I assume comming from the MSDN page, I got that right
    one. But in the past I made a mistake and keep wait for a reply.
    --
    Cheers!

    John
    John Morrill, Jun 28, 2010
    #1
    1. Advertising

  2. John Morrill

    Dooza Guest

    On 28/06/2010 02:32, John Morrill wrote:
    > Greetings!
    >
    > When I create a simple page like this!
    >
    > <html>
    > <head>
    > <title>Test</title>
    > <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript" />


    This should be:

    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript" /></script>

    Dooza
    Dooza, Jun 28, 2010
    #2
    1. Advertising

  3. John Morrill

    Bob Barrows Guest

    Dooza wrote:
    > On 28/06/2010 02:32, John Morrill wrote:
    >> Greetings!
    >>
    >> When I create a simple page like this!
    >>
    >> <html>
    >> <head>
    >> <title>Test</title>
    >> <script src="Scripts/jquery-1.4.1.min.js"
    >> type="text/javascript" />

    >
    > This should be:
    >
    > <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"
    > /></script>
    >

    No it shouldn't. If you want to have an explicit closing tag, you need
    to remove the tag-closer in the opening tag.
    <script src="Scripts/jquery-1.4.1.min.js"
    type="text/javascript"></script>
    --
    HTH,
    Bob Barrows
    Bob Barrows, Jun 28, 2010
    #3
  4. John Morrill

    Dooza Guest

    On 28/06/2010 13:27, Bob Barrows wrote:
    > Dooza wrote:
    >> On 28/06/2010 02:32, John Morrill wrote:
    >>> Greetings!
    >>>
    >>> When I create a simple page like this!
    >>>
    >>> <html>
    >>> <head>
    >>> <title>Test</title>
    >>> <script src="Scripts/jquery-1.4.1.min.js"
    >>> type="text/javascript" />

    >>
    >> This should be:
    >>
    >> <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"
    >> /></script>
    >>

    > No it shouldn't. If you want to have an explicit closing tag, you need
    > to remove the tag-closer in the opening tag.
    > <script src="Scripts/jquery-1.4.1.min.js"
    > type="text/javascript"></script>


    Ah yes, my bad, sorry.

    Dooza
    Dooza, Jun 29, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. showme

    PHP and ASP.NET go HEAD to HEAD

    showme, Jul 8, 2004, in forum: ASP .Net
    Replies:
    13
    Views:
    707
    Sherif ElMetainy
    Jul 10, 2004
  2. shruds
    Replies:
    1
    Views:
    740
    John C. Bollinger
    Jan 27, 2006
  3. John Morrill

    JQuery problem with Javascript in head tag

    John Morrill, Jun 28, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    644
    John Morrill
    Jun 28, 2010
  4. Aaron Gray
    Replies:
    20
    Views:
    378
    Lasse Reichstein Nielsen
    Jul 27, 2008
  5. lorlarz
    Replies:
    6
    Views:
    207
    David Mark
    Mar 25, 2010
Loading...

Share This Page