18 tips for front-end development

Source: Internet
Author: User
1. Try to use UTF-8 encoding for xml files. Some Words in gb2312 cannot be stored, Such ?, Conversion is required even if data can be stored. UTF-8 is also in line with international specifications.

2. In CSS: the hover pseudo class will expire if it is placed before: visited.

3. <a> If a tag does not have the href attribute, all pseudo classes such as hover for its css become invalid.

4. document. wirte ("<script language = 'javascript 'src = '" + file + "'> </" + "script>" format reference, the relative file path is the html path that references the js.

For example, a.htm references x \ B. js, B. js references x \ c. js, the file should be x \ c. js instead of B. js direct path c. js, but the @ import and url () References in css do not have this problem.

5. On the page, sometimes when the width of talbe is set to 100%, a blank scroll bar is left on the right. Set <body style = "overflow: auto">

6. Do not use the img label for commonly used images. Use <span> <a> css to specify the background and width and height. For dynamic images (move to and change the background ), it is best to use <a> without writing additional code, as long as the pseudo class: hover is used. The advantage of using css is to change all changes at a time, this can be well utilized in skin changing applications.

7. @ font-face {font-family: comic; src: url (http: // valid_url/some_font_file.eot );}
Define a font name that is not found locally. Call <span style = "font-family: comic; font-size: 18pt> aa </span>

8. Several CSS
Div {overflow: hidden; text-overflow: ellipsis ;}
Td {vertical-align: middle ;}
[U] to force overflow and apply the ellipsis value, the author must set the white-space attribute value of the object to nowrap. [/U] If there is no chance of wrapping a line (for example, the width of the object container is narrow, and there is a long text with no reasonable broken lines), nowrap may also overflow if it is not applied.
To apply the ellipsis value, this attribute must be set to an object with an invisible area. The best choice is to set the overflow attribute to hidden.

9. firefox's document. createElement does not support HTML tags or innerText, but innerHTML. You can use innerHTML to specify the content.

10. In the. net control, the width of DropDownList in firefox is not colored. You need to define style = 'width: 10px; 'directly ;'

11. The css cursor in firefox does not support hand, instead of pointer.

12. For the scroll bar in iframe, you need to set style = 'overflow: Den den 'in the iframe label. It cannot be set only in the body, but there may be problems in firefox.

13. When you use the onpropertychange event, use event. propertyName to filter attribute change events. When setting this event, the onpropertychange attribute has been changed and will be automatically executed once.

14. Versions of XSL supported in js5.6 are relatively low, which is not supported by document functions.

15. slice functions are slower than getting array fragments through direct loops.

16. When nextSibling is used to obtain the next object, note that there is no space between the two nodes. Otherwise, it is easy to obtain the correct object.

17. When CreateTextFile has a Chinese character, the third parameter must be specified as true. Otherwise, it cannot be written to Chinese, and an error is returned when writing.

18. When saving Chinese text, ADODB. stream is used. fso is not used because FSO does not support UTF-8 format.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.