Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Southern Oregon
    Thanked 1 Time in 1 Post

    DOCTYPE and scripted insertions?

    I have been using xhtml strict doctype and have used my programming text editor
    to test output from php (server side) scripts by copying resulting markup from a view
    source browser window to a temp file and using the text editors doctype checking capacity.
    But, when javascript is used to add content after the page loads, the markup
    is not visible in a view source window.
    So, how would I determine if a browser is not switch to quirks mode because
    the added , or remove content is not compliant.
    I recently have been advised the IE 9 runs javascript differently in quirks mode
    that in standards mode... specifically has both set/removeEventListener and

    Thank you for time and attention

  2. #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Sydney, Australia
    Thanked 932 Times in 919 Posts
    If you use the DOM commands to create and add the extra content then the script will update the DOM directly and the DOM will ensure that it generates valid HTML. At least that will be true provided that you only ever ask it to generate valid DOM elements and attributes.

    At least using the DOM commands will guarantee that a strict page will still remain in standards mode even if you do add invalid tags or attributes.

    It is only if you use innerHTML or document.write that you can directly write to the HTML and potentially write something invalid where the browser will have to interpret what you meant and potentially put the page into quirks mode.
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  3. Users who have thanked felgall for this post:

    anotherJEK (09-21-2012)


Posting Permissions

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