Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2012, 12:21 AM   PM User | #1
milesdriven
Regular Coder

 
Join Date: Dec 2011
Posts: 186
Thanks: 0
Thanked 1 Time in 1 Post
milesdriven is an unknown quantity at this point
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
milesdriven is offline   Reply With Quote
Old 07-05-2012, 08:19 AM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 530 Times in 524 Posts
devnull69 will become famous soon enough
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;
devnull69 is offline   Reply With Quote
Old 07-05-2012, 03:06 PM   PM User | #3
milesdriven
Regular Coder

 
Join Date: Dec 2011
Posts: 186
Thanks: 0
Thanked 1 Time in 1 Post
milesdriven is an unknown quantity at this point
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 05:49 PM..
milesdriven is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:30 PM.


Advertisement
Log in to turn off these ads.