Thế nào là web tĩnh (và thế nào là web động?)

November 20th, 2008

Đôi khi bạn có thể bắt gặp thông báo:

Thông báo: blog đang chuyển sang chế độ web tĩnh để bảo trì

Vậy, web tĩnh là gì? web động là gì?

Các ví dụ về Javascript trên w3schools.com - phần 3 (đối tượng)

November 20th, 2008

Đối tượng liên kết (link - Anchor)

Change text, URL, and target attribute of a link
Using focus() and blur()
Add an accessKey to a link

Đối tượng Document (văn bản)

đáng chú ý có: document.getElementById, innerHTML

Write text to the output
Write text with formatting to the output
Return the title of a document
Return the URL of a document
Return the referrer of a document
Return the domain name of the document’s server
Use getElementById()
Use getElementsByName()
Open a new document, specify MIME type and add some text
Return the number of anchors in a document
Return the innerHTML of the first anchor in a document
Count the number of forms in a document
Access an item in a collection
Count the number of images in a document

Event Object

Which mouse button was clicked?
What are the coordinates of the cursor?
What is the unicode of the key pressed?
What are the coordinates of the cursor, relative to the screen?
What are the coordinates of the cursor?
Was the shift key pressed?
Which element was clicked?
Which eventype occured?

Form and Form Input Objects

View and change the action URL of a form
View the method that is to be used when sending form data
Alert id, type, and value of a Button object + disable button
Check and uncheck a checkbox
Checkboxes in a form
Checkbox - If the user clicks in a checkbox, the content of the text fields are converted to uppercase.
Radio buttons
Reset a form
Submit a form
Form validation
Set focus to an input field when the page loads
Select the content of an input field
Dropdown list in a form
Another dropdown list
A dropdown menu
Jump to the next field when the current field’s maxlength has been reached
Add accessKeys to form fields

Frame, Frameset, and IFrame Objects

Resizable and not resizable frames
Frames with and without scrollbars
Change the source / URL of two frames
Break out of a frame
Update two iframes

Image Object

Change the height and width of an image
Change the src of an image

Location Object

Send the client to a new location / URL
Reload a page
Break out of a frame
Anchors array - This example opens two windows. The first window contains four buttons and the second window defines four anchors from 0 to 3. When a button is clicked in the first window, the onclick event handler goes to the specified anchor in the second window.

Navigator Object

Detect the visitor’s browser and browser version
More details about the visitor’s browser
All details about the visitor’s browser
Alert user, depending on browser

Các hàm thường dùng của các đối tượng

document.getElement

Option and Select Objects

Disable and enable a dropdown list
Get the id of the form that contains the dropdown list
Get the number of options in the dropdown list
Turn the dropdown list into a multiline list
Select multiple options in a dropdown list
Alert the selected option in a dropdown list
Alert the index of the selected option in a dropdown list
Change the text of the selected option
Remove options from a dropdown list

Screen Object

Detect details about the client’s screen

Table, TableHeader, TableRow, TableData Objects

Change the width of a table border
Change the cellPadding and cellSpacing of a table
Specify frames of a table
Specify rules for a table
InnerHTML of a row
InnerHTML of a cell
Create a caption for a table
Delete rows in a table
Add rows to a table
Add cells to a table row
Align the cell content in a table row
Vertical align the cell content in a table row
Align the cell content in a single cell
Vertical align the cell content in a single cell
Change the content of a table cell
Change the colspan of a table row

Window Object

Display an alert box
Alert box with line-breaks
Display a confirm box
Display a prompt box
Open a new window when clicking on a button
Open a new window and control its appearance
Open multiple windows with one click
Send the client to a new location / URL
Reload a page
Write some text in the windows status bar
Print a page
Break out of a frame
Resize a window
Resize a window to a specified size
Scroll the window
Scroll the window to a specified position
Simple timing
Another simple timing
Timing event in an infinite loop
Timing event in an infinite loop - with a Stop button
A clock created with a timing event
Create a pop-up

Các ví dụ về Javascript trên w3schools.com - phần 2 (đối tượng)

November 20th, 2008

Đối tượng String (chuỗi)

Lấy độ dài chuỗi (length)
Dùng thẻ HMTL để trang trí chuỗi
Tìm 1 ký tự trong chuỗi (tìm lần xuất hiện đầu tiên) - indexOf()
Tìm một chuỗi con trong một chuỗi (trả về chuỗi đó hoặc null) - match()
Thay thế các ký tự trong một chuỗi - replace()

Các ví dụ khác về chuỗi xem ở JavaScript reference.

Đối tượng Date (ngày)

Đối tượng Date() trả về ngày hiện thời (dạng 1 chuỗi)
Dùng getTime() để tính năm kể từ năm 1970
Dùng setFullYear() để thiết lập một ngày cụ thể
Dùng toUTCString() chuyển ngày hiện thời (theo UTC) thành một chuỗi
Dùng getDay() và mảng để viết ra các ngày trong tuần
Hiển thị một cái đồng hồ

Các ví dụ khác về ngày xem ở JavaScript reference.

Đối tượng mảng Array

Create an array
Use a for…in statement to loop through the elements of an array
Join two arrays - concat()
Put array elements into a string - join()
Literal array - sort()
Numeric array - sort()

More Array object examples in our JavaScript reference.

Boolean Object

Check Boolean value

More Boolean object examples in our JavaScript reference.

Đối tượng Math (toán học)

Dùng round() để làm tròn số
Dùng random() để lấy một số ngẫu nhiên giữa 0 và 1
Dùng max() lấy số lớn nhất của 2 số
Dùng min() lấy số nhỏ nhất của 2 số
Đổi nhiệt độ từ độ C (Celsius) sang độ F (Fahrenheit)

Các ví dụ về Javascript trên w3schools.com - phần 1 (căn bản)

November 20th, 2008

Cách học hay nhất là thông qua các ví dụ, vì có thể xem được trực tiếp

Ví dụ căn bản về Javascript

Viết ra 1 câu dùng JavaScript
Viết thẻ HTML dùng JavaScript
JavaScript dùng trong thẻ body
JavaScript dùng trong thẻ head
Đặt file JavaScript ở ngoài

Lý thuyết tương ứng


Các câu lệnh, lời chú thích và khối lệnh JavaScript

Các câu lệnh Javascript.
Khối lệnh avaScript.
Chú thích một dòng.
Chú thích nhiều dòng.
Chú thích một dòng để ngăn lệnh thực hiện.
Chú thích nhiều dòng để ngăn lệnh.

Lý thuyết tương ứng


JavaScript Variables

Khai báo biến, gán trị cho biến, hiển thị biến

Lý thuyết tương ứng


Lệnh điều kiện trong JavaScript: If … Else

Lệnh if
Lệnh if…else
Dùng if…else với Math.random để tạo link ngẫu nhiên
Lệnh Switch

Lý thuyết tương ứng


Tạo popup với JavaScript

Hộp thoại Alert
Hộp thoại Alert box có dấu xuống dòng
Hộp thoại Confirm
Hộp thoại Prompt

Lý thuyết tương ứng


Hàm trong JavaScript

Gọi hàm
Gọi hàm với tham số
Gọi hàm với tham số (tiếp)
Hàm trả về một giá trị
Hàm với nhiều tham số, trả về một giá trị

Lý thuyết tương ứng


Vòng lặp trong JavaScript

Vòng For
Dùng vòng lặp tạo ra 6 header từ h1 đến h6
Vòng While
Vòng Do While
Dùng Break thoát khỏi một vòng lặp
So sánh Break và continue trong một vòng lặp
UDùng for…in để lặp trong phạm vi một mảng hoặc tập hợp đối tượng

Lý thuyết tương ứng


JavaScript Error Handling

The try…catch statement
The try…catch statement with a confirm box
The onerror event

Examples explained


Advanced JavaScript Examples

Xem người dùng sử dụng trình duyệt gì, version mấy
More details about the visitor’s browser
All details about the visitor’s browser
Alert user, depending on browser
Sử dụng cookie
Button animation
Image map with added JavaScript
Ứng dụng thời gian đơn giản
Another simple timing
Timing event in an infinite loop
Timing event in an infinite loop - with a Stop button
Làm một cái đồng hồ sử dụng sự kiến thời gian
Create a direct instance of an object
Create a template for an object

3 kiểu viết (hay 3 loại) CSS

November 18th, 2008

Có 3 cách viết CSS:-> thuật ngữ:

  1. inline CSS: CSS trong thẻ
  2. embedded CSS: CSS nhúng
  3. external CSS: CSS ngoài

minh họa bằng hình sau


Entities dùng để làm gì

November 18th, 2008

Sau đây là bài viết (tiếng Anh) : Entities: What are They Good For? = Entities dùng để làm gì?

Q: Tell me about entities in XML documents. What are they and how do I use them?

Q: Hãy cho tôi biết về entities trong tài liệu XML. Chúng là gì và sử dụng chúng như thế nào?

Nguồn: http://www.xml.com/pub/a/98/08/xmlqna0.html

A: After you’re comfortable with XML markup, it’s time to tackle entities. The term entity in the XML Recommendation is used for several related, but slightly different things. There are three things that might loosely be called entities in XML, and we’ll take a detailed look at each of them:

After examining the types of entities available in part 1, part 2 of this article looks at: how and where you must declare entities, some entity attributes, and entity expansion.

Entity Declarations, Attributes and Expansion

Entity Declarations

Entities must be declared before they can be used. They may be declared in the DTD, if your XML parser processes the DTD (also known as the external subset), or the internal subset. Note: if the same entity is declared more than once, only the first declaration applies and the internal subset is processed before the external subset.

All entities are declared with the “ENTITY” declaration. The exact format of the declaration distinguishes between internal, external, and parameter entities.

Declaring Internal Entities

An internal entity declaration has the following form:

<!ENTITY entityname "replacement text">

You can use either double or single quotes to delimit the replacement text. The declaration of yoyo, mentioned earlier, would be:

<!ENTITY yoyo 'Yoyodyne Industries, Inc.'>

Declaring External Entities

External entity declarations come in two forms. If the external entity contains XML text, the declaration has the following form:

<!ENTITY entityname [PUBLIC "public-identifier"]
	SYSTEM "system-identifier">

The system identifier must point to an instance of a resource via a URI, most commonly a simple filename. The public identifier, if supplied, may be used by an XML system to generate an alternate URI (this provides a handy level of indirection on systems that support public identifiers).

An external entity that incorporates chap1.xml into your document might be declared like this:

<!ENTITY chap1 SYSTEM "chap1.xml">

Despite the growing trend to store everything in XML, there are some legacy systems that still store data in non-XML formats. Graphics are sometimes stored in odd formats like PNG and GIF, for example ;-).

External entities that refer to these files must declare that data they contain is not XML. They accomplish this by indicating the format of the external entity in a notation:

<!ENTITY entityname [PUBLIC "public-identifier"]
	SYSTEM "system-identifier" notation>

See the section called Entity Attributes for more detail. An external entity that refers to the GIF image pic01.gif might be declared like this:

<!ENTITY mypicture SYSTEM "pic01.gif" GIF>

Declaring Parameter Entities

Parameter entity declarations are identified by a % preceding the entity name:

<!ENTITY % pentityname1 "replacement text">
<!ENTITY % pentityname2 SYSTEM "URI">

Note the space following the % in the declaration. Parameter entities can be either internal or external, but they cannot refer to non-XML data (you can’t have a parameter entity with a notation).

Entity Attributes

External entities can be further classified as either “parsed” or “unparsed”. Entities which refer to external files that contain XML are called “parsed entities;” entities which refer to other types of data, identified by a notation, are “unparsed.”

The parser inserts the replacement text of a parsed entity into the document wherever a reference to that entity occurs. It is an error to insert an entity reference to an unparsed entity directly into the flow of an XML document. Unparsed entities can only be used as attribute values on elements with ENTITY attributes.

Unparsed entities are used most frequently on XML elements that incorporate graphics into a document. Consider the following brief document:

<!DOCTYPE doc [
<!ELEMENT doc (para|graphic)+>
<!ELEMENT para (#PCDATA)>
<!ELEMENT graphic EMPTY>
<!ATTLIST graphic
        image ENTITY #REQUIRED
        alt   CDATA  #IMPLIED
>

<!NOTATION GIF SYSTEM "CompuServe Graphics Interchange Format 87a">
<!ENTITY mypicture SYSTEM "normphoto.gif" GIF>
<!ENTITY norm "Norman Walsh">
]>
<doc>
<para>The following element incorporates the image declared as
	"mypicture":</para>
<graphic image="mypicture" alt="A picture of &norm"/>
</doc>

You could also declare the image attribute as CDATA and simply type the filename, but the use of an entity offers a useful level of indirection.

Entities in Attribute Values

There is a somewhat subtle distinction between entity attributes and entity references in attribute values. An “ordinary” (CDATA) attribute contains text. You can put internal entity references in that text, just as you can in any other content. An ENTITY attribute can only contain the name of an external, unparsed entity. In particular, note that it contains the name of the entity, not a reference to the entity.

Entity Expansion

Section 4.4 and Appendix D of the XML Recommendation describe all the details of entity expansion. The key points are:

  • Character references are expanded immediately. They behave exactly as if you had typed the literal character.
  • Entity references in the replacement text of other entities are not expanded until the entity being declared is referenced. In other words, this is legal in the internal subset:
    <!ENTITY foobar "&f;bar">
    <!ENTITY f      "foo">

    because the entity reference “&f;” isn’t expanded until “&foobar;” is expanded.

  • Parsed entities are recognized in the body of your document, where unparsed entities are forbidden. Unparsed entities are allowed in entity attributes, where parsed entities are forbidden.
  • Although you can put references to internal entities in attribute values, it is illegal to refer to an external entity in an attribute value.

Caveats

A couple of significant caveats apply to the use of entities:

  • Non-validating parsers are not required to resolve entities declared outside the document (in the external subset). In fact, non-validating parsers may not perform entity expansion at all.
  • At this time (August, 1998), it’s not clear to what extent mainstream web browsers will support entities.

Conclusion

Entity references, while they can perhaps be a little tricky, offer a number of benefits:

  • The ability to define commonly used text in a single location.
  • The ability to break large documents up into workable modules.
  • They offer one possible foundation for a reuse strategy.

Types of Entities

Internal Entities

Do you ever get tired of typing the name of your company, “Yoyodyne Industries, Inc.”? Have you ever had the pleasure of spelling it incorrectly in an important document? Internal entities offer a convenient solution to these problems.

Instead of typing the same text over and over again, you can define an internal entity to contain the text and then you only need to use the entity where you want to insert the text. Because the entity is expanded by the parser, you can be assured that you’ll get the same text in every location. The parser will also catch typos if you misspell an entity name (so long as there’s no entity name that matches your typo!).

To use an entity you insert an “entity reference” into your document. You’re probably already familiar with some entity references because you need to use them for special characters that cannot be typed directly in an XML document, like “<” and “&”. An entity reference is an ampersand (&), followed by the name of the entity, followed by a semicolon (;).

If you’ve defined the entity “yoyo” to contain the name of your company, then you can use it with the following entity reference “&yoyo;“.

The text that is inserted by an entity reference is called the “replacement text”. The replacement text of an internal entity can contain markup (elements, attributes, processing instructions, other entity references, etc.), but the content must be balanced (any element that you start in an entity must end in the same entity) and circular entity references are not allowed.

You create internal entities with entity declarations in the internal subset or the DTD.

Predefined Entities

Five internal entities are predefined in XML:

Table 1. Predefined Entities

Entity Name Replacement Text
lt The less than sign (<)
gt The greater than sign (>)
amp The ampersand (&)
apos The single quote or apostrophe (’)
quot The double quote (”)

All XML processors are required to support references to these entities, even if they are not declared.

Character References

Character references, which are similar in appearance to entity references, allow you to reference arbitrary Unicode characters, even if they aren’t available directly on your keyboard. Character references are not properly entities at all.

Character references are numeric and can be used without any special declaration.

The basic format of a character reference is either “&#nnn;” or “&#xhhh;” where “nnn” is a decimal Unicode character number and “hhh” is a hexadecimal Unicode character number.

A character reference inserts the specified Unicode character directly into your document. Note that this does not guarantee that your processing or display system will be able to do anything useful with the character. For example, &#x236E; would insert, in the words of the Unicode standard, an “APL Functional Symbol Semicolon Underbar”. Whether or not you can print that character is an entirely different issue.

Character references differ from other entity references in a subtle but significant way. They are expanded immediately by the parser. Using ‘&#34;’ is exactly the same as ‘”‘. In particular, this means you can’t use the character reference in an attribute value to escape the quotation characters.

External Entities

External entities offer a mechanism for dividing your document up into logical chunks. Rather than authoring a monolithic document, a book with 10 chapters for example, you can store each chapter in a separate file and use external entities to “source in” the 10 chapters.

Because external entities in different documents can refer to the same files on your file system, external entities provide an opportunity to implement reuse. Reuse of small, discrete components (figures, legal boilerplate, warning messages) is fairly easy to manage. Implementing reuse on a large scale requires an entity management system which XML, by itself, does not provide.

A few notes about external entities:

  • External entities do not have to consist of a single element; you can make a sequence of three paragraphs, or even a bunch of character data with embedded inline markup into an external entity. But the tags in an external entity must be well balanced (you can’t start a tag in an entity and end it in your document or in another entity).
  • External entities can reference internal or other external entities, but you cannot have circular references.
  • You can refer to the same external entity several times in a single document. Note, however, that if you do this, you will have to avoid using ID attributes in the external entity if you’re concerned about validity. Using an external entity which contains an ID in more than one location in your document will produce a document that has multiple, duplicate IDs which is a validity error.
  • It is legal to have several external entities that all refer to the same external file.
  • There are no additional restrictions placed on the character encodings used by external entities. In particular, external entities with differing encodings can be used in the same document.

External entities, like internal entities, have names and are referenced in the same manner, although they are declared differently.

Parameter Entities

Internal and external entity references are not expanded in the DTD or the internal subset (this allows you to use entity references in the replacement text of other entities without concern about the order of declarations). If you want to have the effect of entities and entity references in your DTD, parameter entities must be used. Parameter entity references use the “%” character instead of the “&“. Parameter entities can’t be used in the content of your document; they simply aren’t recognized.

It is legal to have a parameter entity and an internal or external entity with the same name. They are completely different types of entities and cannot conflict with each other.

One common use of parameter entities is in conditional sections. Conditional sections are a mechanism for parameterizing the DTD. Note, however, that you cannot use conditional sections in the internal subset of XML documents.

XML Namespaces

November 18th, 2008

Ví dụ về Namespaces:

<table xmlns="http://www.w3.org/TR/html4/">
   <tr>
   <td>Apples</td>
   <td>Bananas</td>
   </tr>
</table>

This XML carries information about a piece of furniture:

<table xmlns="http://www.w3schools.com/furniture">
   <name>African Coffee Table</name>
   <width>80</width>
   <length>120</length>
</table>

Đọc thêm: http://www.w3schools.com/xml/xml_namespaces.asp

Các bài viết theo “đặt hàng”

November 18th, 2008

Đôi khi tôi nhận được 1 câu hỏi nào đó (trong lớp, trên blog, trên forum, hay qua email, chat …), ví dụ như:

  1. Làm thế nào để học tốt môn C (môn HTML, CSS, Javascript …)?
  2. Làm thế nào để thi qua môn C?
  3. Làm thế nào để trở thành lập trình viên chuyên nghiệp?
  4. Giải bài tập này như thế nào?

Thực tế có một số câu hỏi khó có thể nói vài chữ là xong, nên tôi phải viết hẳn 1 bài viết để trả lời. Sau đây là một số bài tôi trả lời các bạn, và một số câu hỏi tôi dự định sẽ trả lời (nhưng bài đã viết xong các bạn cứ click vào để đọc, bài nào đang viết - nhưng chưa hoàn thiện tôi sẽ chú thích):

  1. 10 bước để thi qua môn thực hành lập trình C (hay EPC) ở Aptech

  2. 10 bước đạt điểm tối đa môn thực hành lập trình C (hay EPC) ở Aptech

  3. 10 bước để trở thành một lập trình viên C chuyên nghiệp (đang viết)

Và 1 số câu hỏi tôi dự định sẽ trả lời:

Làm thế nào học tốt môn lập trình (cụ thể là lập trình C) với người mới bắt đầu học?

Những lỗi thường gặp trong C là gì?

Nếu bạn định hỏi tôi điều gì, hoặc yêu cầu tôi viết bài về vấn đề gì thì cứ comment ở đây nhé, tôi sẽ dành thời gian trả lời bạn khi tôi rảnh. Thường thì tôi sẽ ưu tiên những vấn đề mà nhiều người quan tâm, sau đó đến những vấn đề mà cá nhân tôi thấy hứng thú, sau đó mới đến các vấn đề còn lại.

Thân mến.

YM của lớp C0811HV

November 18th, 2008

Ho Son Tung
tssghost89

tran van ngoc
hoangtu_deche

nguyen van thang
v.th4ng01

doan minh nghia
t4y_m0n_thi3u_gi4

luong phuong dung
lpd_jin

nguyen quang kinh
suotdoitoi_nhomaibonghinhem

Bui Van Chinh
buivanchinh_90

nguyen van hoang
0972116197

nguyen tuan lap
cuopnganhang_duanangdichat_hd

nguyen duy cam
nhatkitinhyeu1990

tran tien thanh
kem_1290

Phan Van
nole_tinhyeu_90hn

Pham Tien Van
anhyeuem_khjbaemlamsep_1990

Nguyen Van Phuc
tinhyeutoihat_trendongsongbang

ngo duy tuan
bohocvuottuong_ditimgai

Nguyen Ngoc Son
teamgeist49

vu tuan nghia
nghiahnxxxx

bui quang vinh
caubethienthan_qv

Ngo duy tien
01668705723

Nguyen Tien phan
shmily_eyo (thày không add được nick này, ko hiểu là do nick sai hay Yahoo đang có vấn đề)

Nguyen duy khang
0972529678

Trang dành cho lớp C0811HV

November 17th, 2008

I. Buổi Lý thuyết 1 - ngày 18/11/2008

- Giới thiệu về thày và blog ohisee

  1. Giới thiệu về thày và blog ohisee: http://ohisee.com/?page_id=2
  2. Nội quy lớp: http://ohisee.com/?p=1427
  3. YM của các bạn trong lớp (sẽ xóa sau buổi Lab thứ 2 để bào đảm tính riêng tư): http://ohisee.com/?p=1777
  4. Địa chỉ download Ebook về HTML, CSS, Javascript: Trong blog cũng có, các em tự tìm, tôi không giới thiệu vì nghĩ việc đọc ebook không có tác dụng lắm

- Bài giảng, slide, code demo, hình ảnh, bài tập:

  1. Thuật ngữ 1 - Ý nghĩa của các thẻ HTML: http://ohisee.com/?p=1349#html-tag
  2. Code demo 1 - Một trang web sử dụng những thẻ html cơ bản: http://dangminhtuan.googlepages.com/1811_web_coban.html
  3. Hình ảnh 1 - Cách lưu một trang web sau khi làm xong:http://dangminhtuan.googlepages.com/1811_cachluuweb.png
  4. Hình ảnh 2 - Cách lưu một hình ảnh để sử dụng cho web: http://dangminhtuan.googlepages.com/1811_luu_png.png
  5. Bài tập 1 - Hãy tạo một trang web trông như sau: http://dangminhtuan.googlepages.com/1811_CVmau_reviewed1.png

- Một số trang web cần học:

  1. W3Schools - Dạy đủ thứ về web - http://www.w3schools.com
  2. Danh sách các free host - http://ohisee.com/?p=978
  3. Các bài học trên ohisee.com về HTML - http://ohisee.com/?cat=162
  4. Các bài học trên ohisee.com về CSS - http://ohisee.com/?cat=163
  5. Các bài học trên ohisee.com về Javascript - http://ohisee.com/?cat=164