SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question HTML 5 & java script (using simply JS book)

    hi,
    I`m trying to learn java script with the Simply java script book but i want to implement it on HTML5 web sites.
    1. is the DOM different in HTML5? like I want to use the getElementsByTagName method, is it different when using an html5 page?

    2. are there other differences between programming Java Script for HTML5 them for XHTML??? and if so how do I overcome those differences.

    thank u for helping.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    HTML 5 is still in draft and is basically HTML 4 with lots of extra tags and attributes added (many of which are completely unnecessary and ought to be removed before it gets much further along the development process). Also since HTML 5 just uses the short version of the HTML 2 doctype there is no way of specifically identifying HTML 5. You can access it via the HTML DOM just the same as for any other version of HTML.

    There are significant differences between using JavaScript with HTML and using it with XHTML as XHTML has its own separate DOM. With XHTML you would use getElementsByTagNameNS in order to specify an additional parameter that defines which namespace that you want to get the tags from.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not really getting what ur saying, I learned HTML5 and now I'm studying java script and I want to use it on my HTML5 built site, is there a different Java script syntax that I should use than the one I would use on XHTML??
    Do you have a reference to a site or article that would help me?

    Thanks alot..

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    With HTML whether it is HTML2 or HTML 5 or anything in between you would use JavaScript with the HTML DOM. The HTML DOM contains commands such as getElementsByTagName('p')

    With XHTML whether XHTML 1.0 or XHTML 5 you would use JavaScript with the XHTML DOM. It contains commands such as getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p")

    In both of those the call is retrieving all of the paragraph tags but in the case of the XHTML one it is specifying that only those that are a part of XHTML namespace re to be retrieved and that any "p" tags that exist in any other namespace within the document should be ignored as they are not paragraphs.

    The whole purpose of XHTML is that it is defined as XML and so you can incorporate any other XML based document type into the same document simply by listing all the namespaces in the xmlns attribute of the html tag - so JavaScript needs to specify which of those namespaces it is processing with a given call.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •