Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts

    the best way for opening javascript?

    Code:
    (1) <script type="text/javascript">
    
    (2) <SCRIPT LANGUAGE="JavaScript"> 
    
    (3) <script>
    Which is the best practice for opening javascript?

    if possible, could you tell my the reason in short?
    Last edited by joonstar; 04-16-2005 at 03:00 AM.
    Get my greedy up

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    The first one is the best way for the script tag, reason being, the 2nd one has language="javascript" which is deprecated and shouldn't be used any more, and the 3rd one, you are missing the type attribute, which is needed if you want it o validate.

  • #3
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Option 1 is the only one you should use.
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Location
    UK
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    JavaScript is the default scripting language, so if you used

    Code:
    <script>
    // code here
    </script>
    Your browser would know its JavaScript but the standard nowadays is the incode type="text/javascript"

  • #5
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    (1) <script type="text/javascript">

    (2) <script language="javascript">
    Which is more recommendable between (1) and (2) in the above quote?
    Get my greedy up

  • #6
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    as stated above, use 1 since language is deprecated.
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #7
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    (1) <script type="text/javascript">
    (2) <script type='text/javascript'>
    Which is more recommendable between double quotation mark and single quotation mark?
    Get my greedy up

  • #8
    New Coder
    Join Date
    May 2005
    Location
    Sydney, Aust
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script type="text/javascript">
    ...
    </script>

    OR

    <script src="/myapp/afile.js" type="text/javascript"></script>
    Last edited by shnplr; 05-22-2005 at 05:26 AM.

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Quote Originally Posted by joonstar
    Which is more recommendable between double quotation mark and single quotation mark?
    Just like in any other HTML attributes, use double quotes.


  •  

    Posting Permissions

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