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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2011
    Posts
    186
    Thanks
    0
    Thanked 1 Time in 1 Post

    Browser is in quirks mode, source is all in one horizontal line and js not working

    I have a page written in html and javascript that works fine. The very first line of this page is:
    Code:
    <!DOCTYPE html>
    The browser renders this page in standards compliant mode with browser source showing horizontal numbered lines running vertically down the page just as they do in the server file.

    Example:
    Code:
    1   horizontal line one
    2   horizontal line two
    etc
    I added a login form that posted username and password to a php script that echoed this very same page back to the browser.

    Now, the javascript does not work at all (only the html and css do), and the browser goes into quirks mode and shows the source code running across the source page in one very long horizontal line.

    Example:
    Code:
    1   one very long horizontal line
    There are no php errors, which is why I don't think this is a php question.

    Does anyone know what it means when a browser puts all the code on 1 long horizontal line, and goes into quirks mode when the code is the same as when it went into standards compliant mode (except it was not wrapped in php), and why this would prevent all javascript from working?

    Do I need to add a header or something?

    I put an example of what I mean by wrapping below. I'm not asking a php question (I don't think), but I'll give this example anyway:
    Code:
    $variable = "<!DOCTYPE>":
    $variable .= "<html>"
    echo "$variable";
    I'm not posting the code itself right now because it would be really long and possibly exceed the character limit. Hopefully there is a simple answer to this that does not require posting of the code.

    I'll try to if someone asks. Thanks

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    It is indeed a PHP question. PHP will not output any line break if you don't print/echo it yourself!
    Code:
    $variable = "<!DOCTYPE>\n<html>";
    echo $variable;

  • #3
    Regular Coder
    Join Date
    Dec 2011
    Posts
    186
    Thanks
    0
    Thanked 1 Time in 1 Post
    Very interesting - thanks.

    Testing shows javascript works in quirks mode as long as everything else is correct. Also, placing that php line break ( \n ) at the end of each line seems to have corrected the problem - so far.

    I have one script working just because of that one change.

    I guess its a javascript engine quirk.
    Last edited by milesdriven; 07-05-2012 at 06:49 PM.


  •  

    Posting Permissions

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