Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘document’

Break up a Code Line in javascript

You can break up a code line within a text string with a backslash. The example below will be displayed properly:

document.write("Hello \
World!");

However, you cannot break up a code line like this:

document.write \
("Hello World!");

Add html element via javascript

// add an element

var fb_foot = document.createElement("div");
fb_foot.id="fb-root";
document.body.appendChild(fb_foot);

 

// import a js file

// e.g load facebook javascript
var tag = document.createElement(‘script’);
tag.type="text/javascript";
tag.src = ‘http://connect.facebook.net/en_US/all.js’;
document.body.appendChild(tag);

HTML vs XHTML

HTML syntax is the format suggested for most authors. It is compatible with most legacy Web browsers. If a document is transmitted with an HTML MIME type, such as text/html, then it will be processed as an HTML document by Web browsers. This specification defines version 5 of the HTML syntax, known as “HTML5″.

XHTML syntax is an application of XML. When a document is transmitted with an XML MIME type, such as application/xhtml+xml, then it is treated as an XML document by Web browsers, to be parsed by an XML processor. Authors are reminded that the processing for XML and HTML differs; in particular, even minor syntax errors will prevent a document labeled as XML from being rendered fully, whereas they would be ignored in the HTML syntax. This specification defines version 5 of the XHTML syntax, known as “XHTML5″.

The DOM, the HTML syntax, and XML cannot all represent the same content. For example, namespaces cannot be represented using the HTML syntax, but they are supported in the DOM and in XML. Similarly, documents that use the noscript feature can be represented using the HTML syntax, but cannot be represented with the DOM or in XML. Comments that contain the string “–>” can only be represented in the DOM, not in the HTML and XML syntaxes.

The term MIME type is used to refer to what is sometimes called an Internet media type in protocol literature. The term media type in this specification is used to refer to the type of media intended for presentation, as used by the CSS specifications.