Rails每周闲碎(五): Http, Html, Browser, etc

前端技巧精粹
本文探讨了前端开发中的关键技巧,包括解决浏览器缓存问题的方法、URL编码原理及其在HTML中的应用、利用label元素提高用户体验、Textarea元素的事件监听、HTTP连接保持机制、以及使用CDATA段确保脚本兼容性。

1. 浏览器的回退

 

    为了避免数据不一致问题,我想到的只有强制禁用浏览器cache(cache control:no cache, no store)。

 

2. Why and how the url is encoded:

 

    http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

 

    and so why some special characters needed to be encoded in HTML? space -> &nbsp. :)

 

 

3. label

 

      html中的label之所以要ID对应,是因为

 

      The label element does not render as anything special for the user. However, it provides a usability improvement for mouse users, because if the user clicks on the text within the label element, it toggles the control.

 

 

<label for="male">Male</label>
<input type="radio" name="sex" id="male" /> 

 

 

4. textarea

 

    oninput和onpropertychange (IE)事件。


5. http keepAlive

 

    Http connection is NOT dropped, but is instead kept open. When the client sends another request, it uses the same connection. This will continue until either the client or the server decides that the conversation is over, and one of them drops the connection.

 

    在Http1.1中,这是默认的。

 

6. cdata

 

    对XHTML兼容,又对现在不支持XHTML的浏览器兼容的方式。

 

 

<script type="text/javascript">
//<![CDATA[                                            
function compare(a,b)
{
if (a < b)
   {alert("a小于b");}
else if (a>b)
   {alert("a大于b");}
else
   {alert("a等于b");}
}
//]]>                                      
</script>

 

    http://www.cnblogs.com/scugzbc/archive/2008/07/13/1242063.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值