SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: <script> tag. forbidden places?

  1. #1
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <script> tag. forbidden places?

    Hello,
    I'm working on page that will need to dynamically (server side) include a few javascript goodies depending on the user input.

    I was wondering, are there some hidden places for the <script> tag? Can I open it in the middle of a page and add a few javascript functions and close it?

    I have seen this numerous times but I was wondering if it was correct.

    Same questions goes for including a remote javascript file.


  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,411
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    You can put JavaScript anywhere you want. Just be aware that JavaScript is parsed in the order it appears on the page so if something at the top of the page is trying to access information you haven't created yet because it is later in the page it won't work.

  3. #3
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can place it in the HEAD or where block level elements are allowed. But you can't place a SCRIPT element where only inline level elements are allowed, such as inside a paragraph.
    Simon Pieters

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zcorpan
    But you can't place a SCRIPT element where only inline level elements are allowed, such as inside a paragraph.
    Code:
    <!ELEMENT P - O (%inline;)* -- paragraph -->
    Code:
    <!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">
    Code:
    <!ENTITY % special
       "A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">
    Birnam wood is come to Dunsinane

  5. #5
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doh! I was thinking about NOSCRIPT...
    Simon Pieters

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, NOSCRIPT is a block-level element and cannot occur inside a paragraph.
    Birnam wood is come to Dunsinane

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •