Bài đăng

Đang hiển thị bài đăng từ tháng 1 3, 2010

Giá trị false trong javascript

The following values are always false: * false * 0 (zero) * "" (empty string) * null * undefined * NaN (a special Number value meaning Not-a-Number!) All other values are truthy, including "0" (zero in quotes), "false" (false in quotes), empty functions, empty arrays, and empty objects.

Lỗi chưa khởi tạo đối tượng trong javascript

Ví dụ: // object constructor function ObjectConstructor(a, b, c) { this.A = a; this.B = b; this.C = c; this.Total = a + b + c; } var obj = ObjectConstructor(1, 2, 3); alert(obj.Total); kết quả trả về không phải bằng 6 mà là chẳng có gì cả. Bởi đối tượng obj chưa được khởi tạo. có 2 cách sửa lỗi này: cách 1: var obj = new ObjectConstructor(1, 2, 3); cách 2: // object constructor function ObjectConstructor(a, b, c) { if (!(this instanceof arguments.callee)) { return new ObjectConstructor(a, b, c); } this.A = a; this.B = b; this.C = c; this.Total = a + b + c; } alert(obj.Total);

Bài rất hay về thiết kế website sử dụng cho tất cả các trình duyệt

Xem <a href="http://www.tjkdesign.com/articles/branching.asp">chi tiết ở đây</a> <h3> The issue with hacks inside styles sheets</h3> Embedding <acronym title="Cascading Styles Sheet">CSS</acronym> filters within a styles sheet may: <dl> <dt>- invalidate the sheet:</dt> <dd>some hacks are "safe", but the validator chokes on more than a few. </dd> <dt>- create unecessary declarations:</dt> <dd>a declaration that targets a <i>single</i> browser is served to <i>all</i> <acronym title="User Agent">UA</acronym>s. </dd> <dt>- create redundant declarations:</dt> <dd>a same attribute is used more than once with <i> different values</i> (see below). </dd> <dt>- create cryptic declarations and rules:</dt> <dd>For example, the <a class="outlink" href=&q

BackGround trong suốt cho IE

Khai báo css: * html img, * html .png {  /* Tên class của div có background là ảnh png trong suốt */     position:relative;     behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",         this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",         this.src = "transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),         this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",         this.runtimeStyle.backgroundImag

The Underscore Hack

The underscore ("_") is allowed in CSS identifiers by the CSS2.1 Specification Browsers have to ignore unknown CSS properties MSIE 5+ for Windows ignores the "_" at the beginning of any CSS property name Therefore, a CSS definition, e. g. _color:red is: Correct, for CSS 2.1 specification allows it (even if software validators, knowing only older version CSS 2.0, say it's a bug: they are wrong, it's correct). Ignored in any browser but WinIE Treated as color:red in WinIE

Khai báo file Robots.txt giúp website bạn có số má cao trong bộ máy tìm kiếm

Khi một search engine tìm đến (nguyên văn Crawler) Website nào đó, nó sẽ tìm một file đặc biệt trước tiên, đó là file robots.txt. File robots.txt cho search engine đó biết rằng, Website này có thể index hoặc không (tùy theo lệnh được viết trong file robots.txt). Ví dụ: User-agent: * Disallow: /support Disallow: /cgi-bin/ Disallow: /images/  ---------------------------------------- User-agent: * Disallow: /images/ Disallow: /cgi-bin/  ---------------------------------------- User-agent: Googlebot-Image Disallow: /  Disallow: /images/mymugshot.jpg +Phải chắc chắn các mệnh đề, từ sử dụng trong lệnh là đúng. Ví dụ  thư mục là "image" (viết thường), nhưng khí vào lệnh, bạn lại viết là "Image" (Viết hoa chữ I) thì các spider sẽ không hiểu. Nói chung phải chính xác tuyệt đối. Xem thêm ở search engine of google để biết nhiều hơn.

Thiết kế giao diện cho website

Designing Web pages is challenging enough without having to build pages that work on every possible combination of Web browser and operating system in existence. So many Web designers choose to take the easy route and design just for the most popular browser, which is IE 6 right now. But if you're going to focus your site on IE 6 you'll be causing some problems for yourself: * When IE 7 comes out, your site will need to be redesigned. * People who use other browsers won't get a good experience. * If new browsers come out and gain popularity, chances are your site won't be able to support them. Standards-Based Web Design Is Best If you design for Web standards then your Web site will be functional with every browser that supports those standards. And even long into the future, your site will stay functional. But Internet Explorer 6 and 5 are not standards compliant. So what do you do? The common response is to design just for them and then try to force your

Giảm dung lượng RAM sử dụng của Firefox

(TNO) Firefox tuy là trình duyệt rất mạnh mẽ nhưng một bất tiện đối với rất nhiều người dùng đó là dung lượng RAM sử dụng tăng lên rất cao sau một khoảng thời gian sử dụng. Điều này làm hiệu suất hoạt động của máy tính bạn giảm hẳn nhưng một số người dùng không hề biết đó là do Firefox. Việc chiếm dụng RAM này do Firefox cache nhiều thông tin vào RAM và cũng do bạn mở quá nhiều thẻ. Vậy làm cách nào để làm Firefox nhẹ nhàng trở lại? 1. Gỡ bỏ bớt các Add-ons: Việc hỗ trợ các Add-ons giúp Firefox có thêm nhiều tính năng mạnh mẽ. Tuy nhiên, càng nhiều Add-ons cài vào thì Firefox càng chiếm dụng ổ cứng và càng chậm chạp. Đó là lý do bạn nên gỡ bỏ các Add-ons không thực sự cần thiết bằng cách vào Tools > Add-ons > Extensions > Uninstall. Nếu bạn không muốn gỡ bỏ hoàn toàn một Add-ons nào đó thì chỉ cần vô hiệu hóa nó với tùy chọn Disable. Nó cũng sẽ giúp Firefox bạn nhẹ hơn và khởi động nhanh hơn. 2. Vô hiệu hóa các Plugins không cần thiết: Bên cạnh các Add-ons, các P