Tags
-
Recent Posts
Recent Comments
Categories
Archives
Links
Tools
Meta
Category Archives: Web
在JavaScript中使用in操作符
今天在阅读jQuery源码的时候看到在if中使用in操作符,发现原来in不仅仅是用在for中,看来对JavaScript的了解实在太少了:) 对我来说最有用的功能是像PHP中的in_array一样使用,其用途可以类似于PHP中的isset(感谢@littlexiang纠正),如下面的代码所示: var arr = [1, 2, 3, 4, 5]; var obj = { “4″: true, “6″:false, “9″:true, “11″:true }; if ( 2 in arr) { alert(’2 in arr’); } else { alert(’2 NOT in arr’); } if ( 4 … Continue reading
IE下Select InnerHTML的问题
在IE下,包括IE8, 9,不能使用innerHTML对select设置option内容,如下面的代码无法得到预期的结果: document.getElementById(‘mySelectId’).innerHTML = ‘ New value ‘; 这个问题在2003年就已经发布在微软支持网站上,但到IE9依然存在这个问题,微软似乎并不把它当成一个问题,详细请参考:http://support.microsoft.com/kb/276228,该文档提出了几种解决方案。 我倾向于采用文章中提到的第三种方法来替代innerHTML: var daysNode = document.getElementById(‘mySelectId’); function updateOptions () { while ( daysNode.firstChild ) { daysNode.removeChild( daysNode.firstChild ); } for (var i = 1; i < 10; i++) { var options = … Continue reading
Magento is encapsulated so deeply!
Magento is encapsulated so deeply as the following image shows, I am wondering does it really suitable for PHP to do so. The following image is a profile for one magento request without Cache, it took a long time to … Continue reading
404错误的一点细节问题
404可能是最常见的HTTP错误了,无论是用户输入地址错误还是因为服务器上文件被删除,大多网站都返回404错误。 1. 通过服务器配置来自定义404错误页面 2. 错误页面的大小应该大于512Byte, 否则IE和Chrome将显示浏览器默认错误页面,也许IE和chrome认为小于512字节的页面不会提供有用信息。 3. 不要跳转到网站前面或其它页面,不要返回其它错误代码, 如200, 302… 服务器配置 在Apache httpd中的配置 ErrorDocument 404 /error/404.html 在nginx中的配置 error_page 404 /error/404.html; location /error/ { root /path/to/error; } 对于PHP,在nginx中还得加上: fastcgi_intercept_errors on; 否则4xx和5xx将不会被返回。 Reference: Hypertext Transfer Protocol — HTTP/1.1 正确处理404错误页面 http://wiki.nginx.org/HttpFcgiModule#fastcgi_intercept_errors
Posted in Web
Leave a comment
配置nginx的SSI
SSI (Server Side Includes) 可以实现静态内容的局部更新,Nginx的HttpSsiModule提供SSI支持, 最简单的配置如下: location ~* \.shtml$ { ssi on; ssi_silent_errors off; } 在HTML页面中可以通过以下命令包含另一个包含动态内容的页面: <!–# include virtual=”/login.php” > 如果需要将参数传递给动态页面,引用nginx的环境变量,如: <!–# include virtual=”/news_list.php?$QUERY_STRING” > 假如包含以上代码的页面是index.shtml, 当访问http://yourdomain.com/path/to/index.shtml?category=2&page=3, 则包含的页面相当于/news_list.php?category=2&page=3. 更多有关SSI的信息: http://wiki.nginx.org/HttpSsiModule http://en.wikipedia.org/wiki/Server_Side_Includes