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ì?
Đô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ì?
Change text, URL, and target attribute of a link
Using focus() and blur()
Add an accessKey to a link
đá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
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?
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
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
Change the height and width of an image
Change the src of an image
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.
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
document.getElement
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
Detect details about the client’s screen
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
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
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() 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.
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.
More Boolean object examples in our JavaScript reference.
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ách học hay nhất là thông qua các ví dụ, vì có thể xem được trực tiếp
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
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.
Khai báo biến, gán trị cho biến, hiển thị biến
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
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
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ị
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
The try…catch statement
The try…catch statement with a confirm box
The onerror event
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
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.
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.
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.'>
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>
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).
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.
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.
Section 4.4 and Appendix D of the XML Recommendation describe all the details of entity expansion. The key points are:
<!ENTITY foobar "&f;bar"> <!ENTITY f "foo">
because the entity reference “&f;” isn’t expanded until “&foobar;” is expanded.
A couple of significant caveats apply to the use of entities:
Entity references, while they can perhaps be a little tricky, offer a number of benefits:
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.
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, 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, ⍮ 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 ‘"’ 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 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, like internal entities, have names and are referenced in the same manner, although they are declared differently.
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.
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
Đô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ư:
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):
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.
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