2013年1月27日 星期日

Browser Cache



  • public — marks authenticated responses as cacheable; normally, if HTTP authentication is required, responses are automatically private.
  • private — allows caches that are specific to one user (e.g., in a browser) to store the response; shared caches (e.g., in a proxy) may not.
  • no-cache — forces caches to submit the request to the origin server for validation before releasing a cached copy, every time. This is useful to assure that authentication is respected (in combination with public), or to maintain rigid freshness, without sacrificing all of the benefits of caching.
  • no-store — instructs caches not to keep a copy of the representation under any conditions.

Reference:
http://www.mnot.net/cache_docs/#CACHE-CONTROL

2013年1月26日 星期六

如何擷取 Browser 可以顯示的寬度和高度 (考量到多螢幕環境)


Firefox、Chrome、IE9:


window.top.innerWidth
window.top.innerHeight


IE8 and previous version:

window.top.document.body.clientWidth
window.top.document.body.clientHeight

2013年1月23日 星期三

Event Handler 如何取得發生 event 的物件

1. this (有瀏覽器相容性的問題)
2. event.srcElement
3. event.target

2013年1月6日 星期日

What is event bubbling and capturing

Event capturing
When you use event capturing
               | |
---------------| |-----------------
| element1     | |                |
|   -----------| |-----------     |
|   |element2  \ /          |     |
|   -------------------------     |
|        Event CAPTURING          |
-----------------------------------
the event handler of element1 fires first, the event handler of element2 fires last.
Event bubbling
When you use event bubbling
               / \
---------------| |-----------------
| element1     | |                |
|   -----------| |-----------     |
|   |element2  | |          |     |
|   -------------------------     |
|        Event BUBBLING           |
-----------------------------------
the event handler of element2 fires first, the event handler of element1 fires last.
Reference: http://www.quirksmode.org/js/events_order.html