Including a Javascript external file from the <body> part of an HTML file

Discussion in 'Javascript' started by davidemazza82@gmail.com, Sep 26, 2007.

  1. Guest

    Hi all,

    I got an [object error] from IE 7.0.5730.11 when moving the <script
    src="..." type="text/javascript" /> tag from the <head> part to the
    <body> section of a HTML file.

    Is not possibile to include Javascript code via <script src="..."
    type="text/javascript" /> from the <body> section, instead from the
    <head> one? If yes, anyone has any idea of which the problem could be?
    If not, how can I programmatically include a javascript external file
    inside the <body> part of a HTML file, for example, using Javascript
    to some particular native functions?

    Tnx a lot

    Bye
    David
    , Sep 26, 2007
    #1
    1. Advertising

  2. On Sep 26, 11:25 am, wrote:
    > I got an [object error] from IE 7.0.5730.11 when moving the <script
    > src="..." type="text/javascript" /> tag from the <head> part to the
    > <body> section of a HTML file.


    Don't use <script ... /> unless you are serving your XHTML as
    application/xhtml+xml, it causes things to break.
    http://www.w3.org/TR/xhtml1/#C_3

    > Is not possibile to include Javascript code via <script src="..."
    > type="text/javascript" /> from the <body> section, instead from the
    > <head> one?


    Yes.

    > If yes, anyone has any idea of which the problem could be?


    Trying to use something in on script that depends on the other script
    running first is a good bet.

    --
    David Dorward
    http://dorward.me.uk/
    http://blog.dorward.me.uk/
    David Dorward, Sep 26, 2007
    #2
    1. Advertising

  3. Henry Guest

    On Sep 26, 11:25 am, wrote:
    > Hi all,
    >
    > I got an [object error] from IE 7.0.5730.11 when moving the
    > <script src="..." type="text/javascript" /> tag from the <head>
    > part to the <body> section of a HTML file.
    >
    > Is not possibile to include Javascript code via <script src="..."
    > type="text/javascript" />


    Not in an HTML document, as the closing script tag is required/
    necessary.

    > from the <body> section, instead from the
    > <head> one?


    There are plenty of valid (in (x) HTML terms) contexts with a BODY
    element into which script elements that import external scripts can be
    placed (and even more where doing so is practical).

    > If yes, anyone has any idea of which the problem could be?


    There are probably millions of things that you could do in order to
    get the error output you suggest. That makes speculation a bit
    pointless.

    > If not, how can I programmatically include a javascript external file
    > inside the <body> part of a HTML file,


    There is no reason for doing it programmatically. Identify the cause
    of the error and address that instead.

    > for example, using Javascript
    > to some particular native functions?


    That does not make sense.
    Henry, Sep 26, 2007
    #3
    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. Dhanasankar S via DotNetMonster.com

    How to read the BODY of HTML file from another HTML file using javascript?

    Dhanasankar S via DotNetMonster.com, Feb 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    463
    =?Utf-8?B?dHBlcnJp?=
    Feb 28, 2005
  2. sravan
    Replies:
    0
    Views:
    2,845
    sravan
    Oct 1, 2004
  3. David D.
    Replies:
    8
    Views:
    150
    Grant Wagner
    Dec 3, 2004
  4. Replies:
    5
    Views:
    209
    A. Sinan Unur
    Sep 8, 2005
  5. Neo Geshel
    Replies:
    36
    Views:
    337
    OmegaJunior
    Mar 18, 2007
Loading...

Share This Page