IE6 changes DOCTYPE to a bad one - doctype

I am working with website that has defined following DOCTYPE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
When I access that website in IE6, DOCTYPE is magically changed to:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
And.. Ok - it can stay because everything looks fine.. But here is the point - just one page has DOCTYPE changed to:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
which I can't stand.
What is the reason of changing XHTML to HTML 4.01 and HTML 4.0 ?
How can I force DOCTYPE in IE6 to XHTML or just HTML 4.01 ?

The reason was unexpected:
HTML comment
placed before <html> tag causes auto change of the page's doctype.

A browser only displays pages, and never modifies the original page.
The only way your question makes sense is if you're doing "save page as" and wondering why the page that IE saved isn't the same as the page it downloaded. In this case I'd expect the browser converts the page into a some sort of internal representation to make it easier to process, and "save page as" converts that internal representation back into HTML; so that it can save a single file (e.g. with embedded CSS rather than a separate CSS file), ensure that the saved file has correct markup (rather than the original potentially un-corrected markup), etc.
If this isn't what you want, go to "view -> page source" and copy & paste that instead.

The only important thing that the doctype does is to force the browser into standards compliance mode. If you don't have a doctype, older browsers will go into Quirks mode; with the doctype (no matter which one you use), the browser will go into Standards mode.
Therefore it really doesn't matter which one you use.
The XHTML doctypes will try to enforce XHTML compliance, but obviously only in browsers that properly support XHTML - IE6 may be problematic here. And of course, specifying XHTML means there's no room for any errors at all, or your page won't be rendered.
Other than that, there's really not much to choose between the various doctypes, so my suggestion is to go with the most up-to-date one possible.... which is the HTML5 doctype.
The HTML5 doctype looks like this:
<!DOCTYPE html>
That's all. Short, simple and to the point. And it does the job for all current browsers (including IE6).
This doesn't mean you have to use any HTML5 features (they obviously won't work IE6 anyway), but it's fully backward compatible, and shouldn't give you any of the weird browser-specific glitches you get with other doctypes.
Hope that helps.

Related

Why does not browser support unicode characters typed in netbeans?

I am using netbeans 7.4 for PHP programming. I have a web form and need to insert a non-English language (Sinhalese)to the interface. I have installed various fonts of this language in my PC and my browser (firefox) renders these fonts properly, because I have viewed local websites using the browser.
Netbeans shows this font as squares and when I run it in the browser something like this කොහොමà·à¶ºà·’is displayed. (Not squares). What is the reason for this? I really do not want to netbeans to show those characters. If the browser can render them, that would be enough.
Answering my own question :)
If you want to display unicode in your browser, you have to include below meta under <head> tag of your html part. Otherwise it won't render non-English content. This worked for me, but netbeans still shows squares for non-English context. I don't mind it since I am using non-english only for user interfaces
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Hope this will help a future reader

Encoding UTF-8 for Czech chars

I want to ask you, as a beginner, what basic settings for the document encoding are you doing with UTF-8?
An example how I do it below and am asking about repair if something is wrong. I want to rely on all devices in different browsers with different user settings will render the text as it should, so I will do the following:
I use Notepad ++ , first in the Format tab choose "change the encoding to UTF-8 (if its already not)";
Because I use <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> mostly or . <!DOCTYPE html>, then select the correct attribute for the meta tag in the head, so either <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> , respectively . <meta charset="UTF-8" />
I'm concerned mainly about the Czech characters
Am I right or isn´t it that simple if I expect cooperation between HTML, PHP or JS, maybe MySQL?
Thank you for your answers and sorry for incomplete English.
If you read text from a Database make sure that it is set to utf8 and that the columns are as well. Then you can use SET NAMES UTF8 to make sure the connection encoding is utf8 as well. Just make it your first query to the databse.

how to create .doc or word file in iphone by code [duplicate]

I have an iPhone app consisting of a few forms in which I collect data from users. Now at the end of these forms, after user has filled all data, I want that all the collected data is exported and a MS word .doc file is generated. The data too is not simple text. There are headings, tables along with normal text in it. Is there any way I can accomplish this?
Short answer yes, long answer:
You can't do this to create "proper" Word documents, however you should be able to acomplish this on any platform by building the word doc from HTML and saving it with a .doc extension (instead of HTML). You can put anything in there, custom layouts - I'd probably stick to paragraphs and tables and floated elements (like imgs and such).
There may be extra code you will need in the HTML doc (for instance to make it open in page view rather than in HTML view) but you can figure all that out by saving a word doc in HTML format. :) There's also a lot of information on the internet about it if you know where to look.
I did something like this not long ago. I'll see if I can find an example and post it here.
Update
This is the only "custom" stuff I have in my html word doc:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
And this - to make it open in Page view:
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Zoom>100</w:Zoom>
</w:WordDocument>
</xml><![endif]-->
The rest of it is just standard HTML and CSS (remember to put CSS INSIDE the HTML document in <style> tags - word isn't going to remotely fetch your css files).
If it is acceptable to be connected when you produce your document, you could use an on-line service like the Docmosis cloud service. It can do the mail merge and deliver the document in various formats. It can be called from iOS.
Hope that helps.
Prepare appropriate html file as per required doc format.
Add this line at the top
<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'>
and save html file as .doc format.
It will resolve your problem.
For more formatting options refer this link.
http://sebsauvage.net/wiki/doku.php?id=word_document_generation

How to generate a word file programmatically from collected data in iPhone sdk

I have an iPhone app consisting of a few forms in which I collect data from users. Now at the end of these forms, after user has filled all data, I want that all the collected data is exported and a MS word .doc file is generated. The data too is not simple text. There are headings, tables along with normal text in it. Is there any way I can accomplish this?
Short answer yes, long answer:
You can't do this to create "proper" Word documents, however you should be able to acomplish this on any platform by building the word doc from HTML and saving it with a .doc extension (instead of HTML). You can put anything in there, custom layouts - I'd probably stick to paragraphs and tables and floated elements (like imgs and such).
There may be extra code you will need in the HTML doc (for instance to make it open in page view rather than in HTML view) but you can figure all that out by saving a word doc in HTML format. :) There's also a lot of information on the internet about it if you know where to look.
I did something like this not long ago. I'll see if I can find an example and post it here.
Update
This is the only "custom" stuff I have in my html word doc:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
And this - to make it open in Page view:
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Zoom>100</w:Zoom>
</w:WordDocument>
</xml><![endif]-->
The rest of it is just standard HTML and CSS (remember to put CSS INSIDE the HTML document in <style> tags - word isn't going to remotely fetch your css files).
If it is acceptable to be connected when you produce your document, you could use an on-line service like the Docmosis cloud service. It can do the mail merge and deliver the document in various formats. It can be called from iOS.
Hope that helps.
Prepare appropriate html file as per required doc format.
Add this line at the top
<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'>
and save html file as .doc format.
It will resolve your problem.
For more formatting options refer this link.
http://sebsauvage.net/wiki/doku.php?id=word_document_generation

Problem With HTML5 Application Cache Whitelist - Won't Ignore Items

I'm trying to use HTML5 Application Cache to speed some things up on an iPhone webapp. It works great for storing images, css and JS, but the problem is that it also tries to store the HTML. I haven't been able to get it to ignore the html and stop storing it in the cache. From what I've read, I have to "whitelist" the files and directories that I want to load no matter what. I've tried listing the files I want cached explicitly, and I've tried adding a series of things under the "NETWORK:" heading. I've tried
*
/
/*
http://mysite.com
http://mysite.com/
http://mysite.com/*
None of them seem to work. Is there any way to ignore HTML files by MIME-Type or anything? Any advice would be appreciated.
Ryan
P.S. Of course, my site is not mysite.com..I just used that for simplicity.
I've avoided this problem by NOT referencing a manifest in each page, instead I have the following within each page :
<iframe src="cache.htm"></iframe> - with styles to hide the iframe
inside cache.htm I have :
<!DOCTYPE html>
<html manifest="cache.manifest">
<head>
<meta charset="UTF-8">
<title>Main Cache Resource</title>
</head>
<body></body>
</html>
based on previous tests and discussions with people in the html5 "ecosystem", each html-page that specifies a manifest is automatically cached as well.