[苗启源]==[Blog.MiaoQiyuan.cn]
百度空间 | 百度首页 
 
文章列表
 
2009年05月12日 23:30
转帖请注明原文地址:http://www.miaoqiyuan.cn/p/asp-yema-fenye/

好久没用ASP写程序了,最近工作需要,想起了以前写的一个ASP分页函数。不过时间太久远了,找不到了。今天我抽空在写个ASP页码函数吧,方便以后工作中使用。
直接写成函数的形式,如果输出生成好的页码,然后又程序输出或保存到文件中。
前十页为一批,第十页显示1,2,3…10;第十一页页码就变成了11,12…20
这种模式很多CMS都用到,比如5UCMS。函数名留点版权信息吧,cs=CatSeven
  1. <%
  2. function csPage(id,all,url1,url2)
  3. if id<>1 then tmp="<a href="""&url1&"1"&url2&""">首页</a> <a href="""&url1&id-1&url2&""">上一页</a> "
  4. istart=((id-1)\10)*10+1
  5. if(all-id)>9 then
  6. iend=((id-1)\10)*10+10
  7. else
  8. iend=all
  9. end if
  10. for i=istart to iend
  11. if i=id then
  12. tmp=tmp&"<span>"&i&"</span> "
  13. else
  14. tmp=tmp&"<a href="""&url1&i&url2&""">"&i&"</a> "
  15. end if
  16. next
  17. if id<>all then tmp=tmp&"<a href="""&url1&id+1&url2&""">下一页</a> <a href="""&url1&all&url2&""">尾页</a>"
  18. csPage=tmp
  19. end function
  20. 'DEBUG
  21. for j=1 to 40
  22. response.write "#Page"&j&":"&csPage(j,40,"#TEST_","_View")&"<br />"
  23. next
  24. %>
复制代码
生成效果如下:
#Page1:1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page2:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page3:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page4:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page5:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page6:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page7:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page8:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page9:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page10:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page11:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page12:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page13:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page14:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page15:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page16:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page17:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page18:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page19:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page20:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page21:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page22:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page23:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page24:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page25:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page26:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page27:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page28:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page29:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page30:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page31:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page32:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page33:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page34:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page35:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page36:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page37:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page38:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page39:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page40:首页 上一页 31 32 33 34 35 36 37 38 39 40
说实话我并不是很喜欢这种分页方式,我比较喜欢上次写的那个。
如果不超过10页,比如共5页。1,2,3,4,5;
如果最末页减当前页码不超过十,页码显示最后10页;
其他的是前四后五的方法。直接给出代码吧
  1. <%
  2. function csPage(id,all,url1,url2)
  3. if id<>1 then tmp="<a href="""&url1&"1"&url2&""">首页</a> <a href="""&url1&id-1&url2&""">上一页</a> "
  4. istart=((id-1)\10)*10+1
  5. if(all-id)>9 then
  6. iend=((id-1)\10)*10+10
  7. else
  8. iend=all
  9. end if
  10. for i=istart to iend
  11. if i=id then
  12. tmp=tmp&"<span>"&i&"</span> "
  13. else
  14. tmp=tmp&"<a href="""&url1&i&url2&""">"&i&"</a> "
  15. end if
  16. next
  17. if id<>all then tmp=tmp&"<a href="""&url1&id+1&url2&""">下一页</a> <a href="""&url1&all&url2&""">尾页</a>"
  18. csPage=tmp
  19. end function
  20. 'DEBUG
  21. for j=1 to 40
  22. response.write "#Page"&j&":"&csPage1(j,40,"#TEST_","_View")&"<br />"
  23. next
  24. %>
复制代码
生成效果如下:
#Page1:1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page2:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page3:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page4:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page5:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page6:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page7:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page8:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page9:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
#Page10:首页 上一页 6 7 8 9 10 11 12 13 14 15 下一页 尾页
#Page11:首页 上一页 7 8 9 10 11 12 13 14 15 16 下一页 尾页
#Page12:首页 上一页 8 9 10 11 12 13 14 15 16 17 下一页 尾页
#Page13:首页 上一页 9 10 11 12 13 14 15 16 17 18 下一页 尾页
#Page14:首页 上一页 10 11 12 13 14 15 16 17 18 19 下一页 尾页
#Page15:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页
#Page16:首页 上一页 12 13 14 15 16 17 18 19 20 21 下一页 尾页
#Page17:首页 上一页 13 14 15 16 17 18 19 20 21 22 下一页 尾页
#Page18:首页 上一页 14 15 16 17 18 19 20 21 22 23 下一页 尾页
#Page19:首页 上一页 15 16 17 18 19 20 21 22 23 24 下一页 尾页
#Page20:首页 上一页 16 17 18 19 20 21 22 23 24 25 下一页 尾页
#Page21:首页 上一页 17 18 19 20 21 22 23 24 25 26 下一页 尾页
#Page22:首页 上一页 18 19 20 21 22 23 24 25 26 27 下一页 尾页
#Page23:首页 上一页 19 20 21 22 23 24 25 26 27 28 下一页 尾页
#Page24:首页 上一页 20 21 22 23 24 25 26 27 28 29 下一页 尾页
#Page25:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页
#Page26:首页 上一页 22 23 24 25 26 27 28 29 30 31 下一页 尾页
#Page27:首页 上一页 23 24 25 26 27 28 29 30 31 32 下一页 尾页
#Page28:首页 上一页 24 25 26 27 28 29 30 31 32 33 下一页 尾页
#Page29:首页 上一页 25 26 27 28 29 30 31 32 33 34 下一页 尾页
#Page30:首页 上一页 26 27 28 29 30 31 32 33 34 35 下一页 尾页
#Page31:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page32:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page33:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page34:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page35:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page36:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page37:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page38:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page39:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页
#Page40:首页 上一页 30 31 32 33 34 35 36 37 38 39 40

转帖请注明原文地址:http://www.miaoqiyuan.cn/p/asp-yema-fenye/
 
2008年12月07日 15:06

个性生活,从DIY书籍,个人出书出书开始
自古以来,中国读书人都有出版文集传诸后世的雅兴。可以说个人出书在中国古代很流行,但新中国成立后,GJ实行了出版管制,个人出书就增加了很多难度;SC经济后,出版社只出版能快速获取经济利益的书籍,如果想个人出书,恐怕就要动辄几万元的成本费用。
难道作为一个天天写博客草根,个人出书就没有希望了吗?今天我为大家提供一个个人出书的方法,即使仅一本书,也可是出版,想个人出书的博主也可以来DIY一下在即的书籍,做DIY一本超级个性的书籍,也过一把个人出书瘾。

出版的程序包括:
  • 完成作品并录入/排版,设计封面,做到稿件齐、清、定;
  • 直接向出版社编辑部门投稿或者找代理人代理出版您的作品;
  • 由出版社或者代理人初步审核选题、稿件,签署出版合同或代理合同;
  • 交纳相关费用:出版管理费(书号费)、编审费(部分出版社不收取或者包含在管理费之中);
  • 进入出版环节(若代理出版一般为一个月左右或者更短时间);
  • 审稿完成后,由出版社发取书号、CIP、委印单等(部分有发行委托书);
  • 印刷-发行。
图书出版需要准备以下材料:
  • 书名(可以是暂定名)、内容简介、作者及简介、目录、样章;
  • 稿件:要求齐、清、定,即是排好版的全稿/定稿;
  • 向出版社的作品授权书(您还需要提供原著作者或出版社的授权书)。
出书的费用,至少需要2万元以上:
  • 印前设计:录排(含出片)、封面设计(含出片)
  • 出版:书号费(管理费)、编审费
  • 印刷:封面印刷(含纸张、印刷、覆膜、后期)、内文纸张、内文印刷、装订
出书预算:假设书为传统的大32开,300页,单本单号,单色、胶版纸印刷一万册。
  • 书号费10000~15000元,编审费0~2000元,计10000~17000元
  • 稿费:3000~10000元
  • 设计、录排、出片费用3000元
  • 纸张、印刷、装订30000元
  • 其他费用(仓储物流通联管理等)5000元

出书这么这么难,难道我们就应该放弃吗?
不,如今有了超印速,个人出书不是梦。

超印速网站是上海华凡信息技术有限公司在大陆地区首家提供“个性印书,一本起印”服务的网站,无论是诗歌散文,还是博客相册,强大的设计能力和技术支持都为用户提供了专业的排版审稿服务。最简单的操作,三四十元的价格让每一个普通人可以立即拥有完全属于自己的专业书籍。“让印书不再是梦想”,这是超印速致力于追求和探索的目标。

有了超印速,我们个人出书有望了。现在注册还有机会获得免费印书20本书的机会。还等是么,快来注册吧。个人出书 的方法请访问http://miaoqiyuan.cn/chushu

 
2008年11月24日 22:38

今天上百度,砍价网友留言说我懒了,呵呵,实际我一直都有写文章,不过都在自己的网站上写,没有复制过来,太多了,发个链接吧

更多请访问:http://miaoqiyuan.cn/sitemap

图片批量转换工具

使用Server.Transfer轻松用ASP实现Rewrite模拟生成静态页效果

ASP使用BinaryWrite与Adodb.Stream实现下载

Python中文文档-Google免费空间必看

asp/php下生成GUID

ASP ServerVariables 路径操作 简易教程

css实现层叠背景图实现多个图层叠加

Vista 激活破解方法

HTTP-REFERER+Session,给您的CMS加道万能锁

ADOX.Catalog简易中文文档

QQ一键登陆代码

WScript的SendKey

ASPJPEG中文教程(文档)

Workeasy-简单客户网站信息管理系统

Workeasy之不变形批量转换图片文件大小

Workeasy之图片文件统计打印

WorkEasy之上传图片预览工具

分析某FlashAPI调用–发现一个好用的JS框架,MyW3SYS应用实例

禁用VS2005实时调试

纯真IP数据库转MDB/MSSQL/MySQL

css技巧-经典中的经典

VS2008正式版,提供序列号

IE6背景透明的方法

Nginx+PHP 可承受3万以上并发连接数

浅谈如何选择广告联盟之交换链接

做Google AdSense被差点饿死的痛苦经历

淘宝拍拍店铺有福了:网店新规终于走向了末路

IE Developer Toolbar Beta 3 - Now Available

asp生成xls(EXCEL文件)

ASP输出DOC(Word文件)

项目开发,我用类

电脑裸奔,百毒不侵

跨浏览器实现float:center

用YSlow分析我们页面

网页中英文混排行高不等问题

历届奥运会举办地和金牌最多的国家

FlyCatGameCMS DEMO版本今日发布

FF支持浮动层,Firefox-clientX

Firefox的document.body.scrollTop

寻有识之士共同开发SNS API插件

游戏CDKEY发布平台(FlyCat Game CMS) 程序完成

服务器对象 错误 ASP 0177 : 800401f3

Request 对象 错误 ‘ASP 0104 : 80004005′ 不许操作

100多个IP不作弊,每天至少赚1元的秘密

SuperHost Pro 下载(购买)地址

SuperHost v1.0,代替IIS的工具支持虚拟主机

站长前辈的经验分享:城市门户网站宣传推广建议

仙剑五路在何方?国产单机游戏最后一个样板——软星七年

用shtml来include网页文件(开启SSI)

W3C-DOM简要文档

Js中 关于top、clientTop、scrollTop、offsetTop等

伪静态(Rewrite).htaccess文件使用教程

document的使用方法

CSS Hack兼容大全,令您的网页能正常显示在IE5,IE5.5,IE6,IE7,Firefox,Opera,Safari…

ColorMan颜色调试工具V1.0 VB6编写

ASP生成LI+CSS无限级菜单

找工作了

理发了(文章很乱,主要针对搜索引擎优化的页面)

IPDB

Javascript本地文件搜索工具

能轻松加入FLASH,获取URL提交的数据,获取DOM对象并能轻松修改ClassName的JS框架:myw3sys

ASP文件搜索系统

asp编写的仿Explorer资源管理器

mysql数据库导入错误 error1064

firefox与ie 的javascript 兼容问题

auto病毒解决方案(加密狗nboqcey.exe,afdyvnr.exe,fhrqdpi.exe清理工具):病毒工具包

Web3D,据我还有多远?

新写的一个CSS-Tabs

五级三节制 算法及畅想

用JavaScript获取Get提交的参数

WordPress无Rewrite用cos-html-cache实现静态化

域名批量查询工具by苗启源,每次查500个域名

我的阿里UED答题

防止病毒Auto病毒程序新思路

以前写的九九乘法表[JavaScript]

wordpress建博客,选择一个好的模板[37个模板站点+模板中文显示不正常解决方案]

 
2008年07月13日 18:49
本人博客已经迁至:http://www.miaoqiyuan.cn/
 
2008年06月09日 23:14
[文章作者:张宴 本文版本:v1.3 最后修改:2007.11.06 转载请注明出处:http://blog.s135.com]

  本文已经有新版本:Nginx 0.5.33 + PHP 5.2.5(FastCGI)搭建胜过Apache 10倍的Web服务器(第2版)


  Nginx ("engine x") 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。

  Nginx 的中文维基:http://wiki.codemongers.com/NginxChs

  在高并发连接的情况下,Nginx是Apache服务器不错的替代品。Nginx同时也可以作为7层负载均衡服务器来使用。根据我的测试结果,Nginx 0.5.31 + PHP 5.2.4 (FastCGI) 可以承受3万以上的并发连接数,相当于同等环境下Apache的10倍

  以下是 Nginx 0.5.31 + PHP 5.2.4 (FastCGI) 服务器在3万并发连接下的TCP状况:
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

  各种状态TCP连接数如下(各项值所代表的含义见我的另一篇文章《查看Apache并发请求数及其TCP连接状态》):
引用
LAST_ACK 1
SYN_RECV 991
CLOSE_WAIT 1
ESTABLISHED 18789
FIN_WAIT1 1478
FIN_WAIT2 181
TIME_WAIT 506

  根据我的经验,4GB内存的服务器+Apache(prefork模式)一般只能处理3000个并发连接,因为它们将占用3GB以上的内存,还得为系统预留1GB的内存。我曾经就有两台Apache服务器,因为在配置文件中设置的MaxClients为4000,当Apache并发连接数达到3800时,导致服务器内存和Swap空间用满而崩溃。

  而这台 Nginx 0.5.31 + PHP 5.2.4 (FastCGI) 服务器在3万并发连接下,开启的10个Nginx进程消耗100M内存(20MB*10=100M),开启的250个php-cgi进程消耗1G内存(4MB*250≈1GB),加上系统自身消耗的内存,总共才消耗2GB内存。如果服务器内存较小,完全可以只开启25个php-cgi进程,这样php-cgi消耗的总内存数才100M。在开启25个php-cgi进程的情况下,每分钟的处理能力只比开启250个php-cgi进程时低了不到一半。

  以下为 Nginx 0.5.31 + PHP 5.2.4 (FastCGI) 服务器在3万并发连接下,开启的10个Nginx进程和250个php-cgi进程时的系统负载情况:
  点击在新窗口中浏览此图片


  安装步骤:
  (系统要求:Linux 2.6+ 内核,本文中的Linux操作系统为CentOS 4.4)

  一、获取相关开源程序:
  1、下载程序源码包到当前目录:
  本文中提到的所有开源软件为截止到2007年9月21日的最新稳定版。我将它们打了两个压缩包。

  第一个压缩包:nginx_php_mysql_1.0_1of2.zip:
  下载地址:http://ishare.iask.sina.com.cn/cgi-bin/fileid.cgi?fileid=2289607

  第二个压缩包:nginx_php_mysql_1.0_2of2.zip:
  下载地址:http://ishare.iask.sina.com.cn/cgi-bin/fileid.cgi?fileid=2289595

  2、解压缩:
unzip nginx_php_mysql_1.0_1of2.zip
unzip nginx_php_mysql_1.0_2of2.zip



  二、安装PHP 5.2.4(FastCGI模式)
  1、编译安装PHP 5.2.4所需的支持库:
tar zxvf libiconv-1.11.tar.gz
cd libiconv-1.11/
./configure --prefix=/usr/local/webserver/lib/libiconv
make && make install
cd ../

tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5/
./configure --prefix=/usr/local/webserver/lib/freetype
make && make install
cd ../

tar zxvf libpng-1.2.20.tar.gz
cd libpng-1.2.20/
./configure
make && make install
cd ../

tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure --enable-static --enable-shared
make && make install
cd ../

tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35/
./configure --prefix=/usr/local/webserver/lib/gd --with-freetype=/usr/local/webserver/lib/freetype --with-jpeg --with-png
make
make install
cd ../

tar zxvf libxml2-sources-2.6.30.tar.gz
cd libxml2-2.6.30/
./configure --prefix=/usr/local/webserver/lib/libxml
make && make install
cd ../



  2、编译安装MySQL 5.0.45
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.0.45.tar.gz
cd mysql-5.0.45
./configure --prefix=/usr/local/webserver/mysql/ --without-debug --with-unix-socket-path=/tmp/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=gbk,gb2312,utf8 --with-pthread --enable-thread-safe-client
make && make install
chmod +w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cp support-files/my-medium.cnf /usr/local/webserver/mysql/my.cnf



  附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,则执行以下两步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下两步无需执行。
  ①、以mysql用户帐号的身份建立数据表:
/usr/local/webserver/mysql/bin/mysql_install_db --defaults-file=/usr/local/webserver/mysql/my.cnf --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data --user=mysql --pid-file=/usr/local/webserver/mysql/mysql.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock


  ②、启动MySQL(最后的&表示在后台运行)
/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/usr/local/webserver/mysql/my.cnf &



  3、编译安装PHP(FastCGI模式)
cd ..
tar zxvf php-5.2.4.tar.gz
cd php-5.2.4/
./configure --prefix=/usr/local/webserver/php --with-mysql=/usr/local/webserver/mysql --with-config-file-path=/usr/local/webserver/php/etc --with-gd=/usr/local/webserver/lib/gd --enable-gd-native-ttf --enable-gd-jis-conv --with-iconv-dir=/usr/local/webserver/lib/libiconv --with-freetype-dir=/usr/local/webserver/lib/freetype --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-zlib --with-libxml-dir=/usr/local/webserver/lib/libxml --enable-xml --disable-debug --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-force-cgi-redirect
make && make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../



  附:编译PHP之后,为PHP添加扩展的方法。(本步骤可选)
cd php-5.2.4/pcntl
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make && make install
cd ../../../


vi /usr/local/webserver/php/etc/php.ini

修改extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"


  4、创建www用户和组,以及其使用的目录:
/usr/sbin/groupadd www -g 48
/usr/sbin/useradd -u 48 -g www www
mkdir -p /data0/vshare/htdocs
chmod +w /data0/vshare/htdocs
chown -R www:www /data0/vshare/htdocs


  5、安装lighttpd中附带的spawn-fcgi,用来启动php-cgi
  注:压缩包中的spawn-fcgi程序为已经编译成二进制的版本。
cp spawn-fcgi /usr/local/webserver/php/bin
chmod +x /usr/local/webserver/php/bin/spawn-fcgi


  6、启动php-cgi进程,监听127.0.0.1的10080端口,进程数为250(如果服务器内存小于3GB,可以只开启25个进程),用户为www:
/usr/local/webserver/php/bin/spawn-fcgi -a 127.0.0.1 -p 10080 -C 250 -u www -f /usr/local/webserver/php/bin/php-cgi



  三、安装Nginx 0.5.31
  1、安装Nginx所需的pcre库:
tar zxvf pcre-7.2.tar.gz
cd pcre-7.2/
./configure
make && make install
cd ../


  2、安装Nginx
tar zxvf nginx-0.5.31.tar.gz
cd nginx-0.5.31/
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx
make && make install
cd ../


  3、创建Nginx日志目录
mkdir -p /data1/logs
chmod +w /data1/logs
chown -R www:www /data1/logs


  4、创建Nginx配置文件
  ①、在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件:
rm -f /usr/local/webserver/nginx/conf/nginx.conf
vi /usr/local/webserver/nginx/conf/nginx.conf

  输入以下内容:
引用
user www www;

worker_processes 10;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
{
use epoll;

#maxclient = worker_processes * worker_connections / cpu_number
worker_connections 51200;
}

http
{
include conf/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /data1/logs/access.log main;

#sendfile on;
#tcp_nopush on;

keepalive_timeout 60;

#gzip on;

server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /data0/vshare/htdocs;

if (-f $request_filename/index.html)
{
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.htm)
{
rewrite (.*) $1/index.htm break;
}
if (-f $request_filename/index.php)
{
rewrite (.*) $1/index.php break;
}

location ~ .*\.php?$
{
include conf/fcgi.conf;
fastcgi_pass 127.0.0.1:10080;
fastcgi_index index.php;
}
}
}


  ②、在/usr/local/webserver/nginx/conf/目录中创建fcgi.conf文件:
vi /usr/local/webserver/nginx/conf/fcgi.conf

  输入以下内容:
引用
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param REDIRECT_STATUS 200;


  5、启动Nginx
ulimit -SHn 51200
/usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf



  四、配置开机自动启动Nginx + PHP
vi /etc/rc.local

  在末尾增加以下内容:
引用
/usr/local/webserver/php/bin/spawn-fcgi -a 127.0.0.1 -p 10080 -C 250 -u www -f /usr/local/webserver/php/bin/php-cgi
ulimit -SHn 51200
/usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf



  五、优化Linux内核参数
vi /etc/sysctl.conf

  在末尾增加以下内容:
引用
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000


  使配置立即生效:
/sbin/sysctl -p


 
2008年04月15日 01:22

Godaddy如何购买图解:    http://www.stahosting.com/thread-34-1-2.html
Godaddy购买省钱策略:    http://www.stahosting.com/thread-121-1-7.html
Godaddy主机使用图解: http://www.stahosting.com/thread-35-1-1.html

————————————————————————————————————————

优惠券: cjchost20 购买所有主机产品优惠20%.
有效期: 无限制

优惠券: cjcdeal 购买75美元以上优惠15%
有效期: 无限制

优惠券: cjctenoff 购买50美元及以上可以优惠10美元
有效期: 无限制

优惠券: cjc20host 购买所有主机产品优惠20%.
有效期: 无限制

优惠券: cjcsave 购买所有主机产品满30元优惠5元.
有效期: 无限制

优惠券:cjc20off75   购买75美元及以上可以优惠20美元
有效期:无限制

优惠码: cjc695dom $6.95 .COM 注册,续费,转移
有效期: N/A

GoDaddy.com SSL证书优惠

14.99美金一年

优惠连接,点后看到的还是29.99美金,选到购物车后就是14.99美金/年了

 
2008年04月11日 11:07

真不知道你们这帮孩子怎么想的~

这样做又意思吗?

附件

1.gif (28.2 KB)

2008-1-10 20:01

1.gif

2.gif (41.84 KB)

2008-1-10 20:01

2.gif

3.gif (28.06 KB)

2008-1-10 20:01

3.gif

4.gif (30.14 KB)

2008-1-10 20:01

4.gif

5.gif (48.46 KB)

2008-1-10 20:01

5.gif

6.gif (16.45 KB)

2008-1-10 20:01

6.gif

7.gif (33.24 KB)

2008-1-10 20:01

7.gif

8.gif (22.99 KB)

2008-1-10 20:01

8.gif

9.gif (33.24 KB)

2008-1-10 20:01

9.gif

10.gif (55.89 KB)

2008-1-10 20:01

10.gif

11.gif (128.86 KB)

2008-1-10 20:01

11.gif

 
2008年03月02日 13:45

ASP网站数据采集程序制作:一个采集入库生成本地文件的几个FUCTION(可用来生成HTML静态网页)

看着一个又一个网站系统里都带了采集功能模块,让我心动,很想让自己做的网站里也带个采集模块,可惜一直都不知道如何下手,现在有了这几个函数,你也可以制作出自己的采集程序,而且可以利用这样的原理来生成HTML静态网页.

本文里介绍采集程序的方法分成以下几个函数来实现:

1:SaveFiles(byref from,byref tofile)
作用 :利用流保存文件
' 参数 :from(远程文件地址),tofile(保存文件位置)

2:IsExists(byref filespec)
作用 :利用fso检测文件是否存在,存在返回true,不存在返回false
' 参数 :filespes(文件位置)

3:IsFolder(byref Folder)
作用 :利用fso检测文件夹是否存在,存在返回true,不存在返回false
' 参数 :folder(文件夹位置)

4:CreateFolder(byref fldr)
作用 :利用fso创建文件夹
' 参数 :fldr(文件夹位置)

5:SaveData(byref FromUrl,byref ToFiles)
作用 :保存文件,并自动创建多级文件夹
' 参数 :fromurl(远程文件地址),tofiles (保存位置)

6:GetData(byref url,byref GetMode)
作用 :取得远程数据
' 参数 :url(远程文件地址),getmode (模式:0为二进制,1为中文编码)

7:FormatImgPath(byref ImgUrl,byref ImgFolder,byref FristName,byref noimg)
作用 :格式化远程图片地址为本地位置
' 参数 :imgurl(远程图片地址),imgfolder (本地图片目录),fristname(加入的前缀名称)

有了以上这7个函数,你就可以做一个简单的网站数据采集程序了,下面贴出实现的详细代码.

--------------------------------------------------------------------------------


'*****************************************************************
' function
' 作用 :利用流保存文件
' 参数 :from(远程文件地址),tofile(保存文件位置)
'*****************************************************************
Private Function SaveFiles(byref from,byref tofile)
Dim Datas
Datas=GetData(from,0)
Response.Write "保存成功:<font color=red>"&formatnumber(len(Datas)/1024*2,2)&"</font>Kb"
response.Flush
if formatnumber(len(Datas)/1024*2,2)>1 then
ADOS.Type = 1
ADOS.Mode =3
ADOS.Open
ADOS.write Datas
ADOS.SaveToFile server.mappath(tofile),2
ADOS.Close()
else
Response.Write "保存失败:<font color=red>文件大小"&formatnumber(len(imgs)/1024*2,2)&"Kb,小于1K</font>"
response.Flush
end if
end function

'*****************************************************************
' function(私有)
' 作用 :利用fso检测文件是否存在,存在返回true,不存在返回false
' 参数 :filespes(文件位置)
'*****************************************************************
Private Function IsExists(byref filespec)
If (FSO.FileExists(server.MapPath(filespec))) Then
IsExists = True
Else
IsExists = False
End If
End Function


'*****************************************************************
' function(私有)
' 作用 :利用fso检测文件夹是否存在,存在返回true,不存在返回false
' 参数 :folder(文件夹位置)
'*****************************************************************
Private Function IsFolder(byref Folder)
If FSO.FolderExists(server.MapPath(Folder)) Then
IsFolder = True
Else
IsFolder = False
End If
End Function

'*****************************************************************
' function(私有)
' 作用 :利用fso创建文件夹
' 参数 :fldr(文件夹位置)
'*****************************************************************
Private Function CreateFolder(byref fldr)
Dim f
Set f = FSO.CreateFolder(Server.MapPath(fldr))
CreateFolder = f.Path
Set f=nothing
End Function

'*****************************************************************
' function(公有)
' 作用 :保存文件,并自动创建多级文件夹
' 参数 :fromurl(远程文件地址),tofiles (保存位置)
'*****************************************************************
Public Function SaveData(byref FromUrl,byref ToFiles)
ToFiles=trim(Replace(ToFiles,"//","/"))
flName=ToFiles
fldr=""
If IsExists(flName)=false then
GetNewsFold=split(flName,"/")
For i=0 to Ubound(GetNewsFold)-1
if fldr="" then
   fldr=GetNewsFold(i)
else
   fldr=fldr&"\"&GetNewsFold(i)
end if
If IsFolder(fldr)=false then
   CreateFolder fldr
End if
Next
SaveFiles FromUrl,flName
End if
End function
'*****************************************************************
' function(公有)
' 作用 :取得远程数据
' 参数 :url(远程文件地址),getmode (模式:0为二进制,1为中文编码)
'*****************************************************************
Public Function GetData(byref url,byref GetMode)
'on error resume next
SourceCode = OXML.open ("GET",url,false)
OXML.send()
if OXML.readystate<>4 then exit function
if GetMode=0 then
GetData = OXML.responseBody
else
GetData = BytesToBstr(OXML.responseBody)
end if
if err.number<>0 then err.Clear
End Function

'*****************************************************************
' function(公有)
' 作用 :格式化远程图片地址为本地位置
' 参数 :imgurl(远程图片地址),imgfolder (本地图片目录),fristname(加入的前缀名称)
'*****************************************************************
Public Function FormatImgPath(byref ImgUrl,byref ImgFolder,byref FristName,byref noimg)
strpath=""
ImgUrl=ImgUrl
if instr(ImgUrl,"Nophoto") or lenb(GetData(ImgUrl,0))<=0 then
strpath=noimg
Response.Write "<a href="&strpath&">"&strpath&"</a>" &vbcrlf
else
if Instr(ImgUrl,".asp") then
   strpath=FristName&"_"&Mid(ImgUrl, InStrRev(ImgUrl, "=")+1)&".jpg"
else
   strpath=FristName&"_"&Mid(ImgUrl, InStrRev(ImgUrl, "/")+1)
end if
strpath = ImgFolder&"/"&strpath
strpath = Replace(strpath,"//","/")
if left(strpath,1)="/" then strpath=right(strpath,len(strpath)-1)
strpath = trim(strpath)
Response.Write "<a href="&strpath&">"&strpath&"</a>" &vbcrlf
savedata ImgUrl,strpath
end if
FormatImgPath = strpath
End function

 
2008年02月01日 21:28
比特网(ChinaByte)2月1日评论(王培垠) 雅虎,曾经的互联网巨擘,将可能被微软这个软件巨人收编,成为对抗谷歌的力量。微软已经强行要求与雅虎展开实质性的收购谈判。

  微软可能以500亿美元的要约价格发起这一并购,这一价格已经显示,微软已经没有耐心等待,过去一段时间以内,微软屡次在竞购新兴互联网商业中败给谷歌、DoubleClick的竞购出局。与AOL重签广告协议出局,太多的失败已经打击了微软与谷歌竞争的士气,针对雅虎的收购,微软太需要一场胜利来巩固在互联网领域并不牢固的地位。

  甚至,用户对基于互联网的应用越来越感兴趣,谷歌发展出的互联网办公软件环境,已经威胁微软Office的销售。

  目前,雅虎首个季度的业绩延续了一如既往的低迷,裁员的愁云笼罩雅虎,如果雅虎与微软达成协议,微软将得到雅虎的互联网用户和市场份额,使其与谷歌的差距不至于那么遥远。目前,谷歌占据了65%的市场份额,受此消息刺激,雅虎的股票价格已经得到资本市场的密切关注并开始大涨。

 
2008年01月23日 17:07

IE6IE7共存,将要安装IE7或恢复到IE6的用户请看

即将要恢复到IE6,卸载IE7的请看:
装了IE,不用卸载也能用IE6(CSS调试工具Multiple IE)

即将要安装IE7的请看
不用安装IE7,也能运行IE7(IE7绿色版)

 
2007年11月13日 21:19

http://www.miaoqiyuan.cn

 
2007年11月08日 23:03

怀念666CCC音乐下载程序,写了简单百度/谷哥小偷~

选择百度搜索,苗启源

选择Google,搜索苗启源

<form action="#">
简单的搜索引擎 V1.0 By 苗启源 HomePage:http://hi.baidu.com/mqycn 关键字:<input type="text" value="" name="key" />
选择站点:<select name="so">
<option value="baidu">百度
<option value="google">Google
</select>
<input type="submit" value="立即搜索">
</form> <hr />
<script language="javascript">
var _mqycn_url=location.href.split("?")
var _mqycn_key,_mqycn_so,_mqycn_var,_mqycn_array,_mqycn_mqycn;
if(_mqycn_url[1]){
_mqycn_array=_mqycn_url[1].split("&")
for(i=0;i<_mqycn_array.length;i++){
   _mqycn_var=_mqycn_array[i].split("=");
   if(_mqycn_var[0]=="so"){_mqycn_so=_mqycn_var[1]}
   if(_mqycn_var[0]=="key"){_mqycn_key=_mqycn_var[1]}
}
_mqycn_mqycn="mqycn.asp?";
if(_mqycn_so){_mqycn_mqycn+="so="+_mqycn_so+"&"}
if(_mqycn_key){_mqycn_mqycn+="key="+_mqycn_key+"&"}
_mqycn_mqycn="<script language=\"javascript\" src=\""+_mqycn_mqycn+"\"><\/"
_mqycn_mqycn+="script>"
document.write(_mqycn_mqycn);
}else{
location.href="#?so=google&key=mqycn";
}
</script>
<hr>
<form action="#">
简单的搜索引擎 V1.0 By 苗启源 HomePage:http://hi.baidu.com/mqycn 关键字:<input type="text" value="" name="key" />
选择站点:<select name="so">
<option value="baidu">百度
<option value="google">Google
</select>
<input type="submit" value="立即搜索">
</form> <hr />

 
2007年11月08日 22:24

新写的一个显示百度和google搜索结果的工具,感谢百度网友ailvyou提出!

default.htm代码为:<script language="javascript" src="mqycn.asp?so=baidu&key=苗启源"></script>

default.htm代码为:<script language="javascript" src="mqycn.asp?so=google&key=mqycn"></script>

<%
'用ASP写的~
'能返回关键字的结果,但是还没有做到返回20条
'这不是最好的解决方案,最好用XMLHttpRequest()返回数据,通过JavaScript控制DOM显示,但是返回的都是码,小弟刚学Ajax,只能做到这样了~


'保存为mqycn.asp,用JavaScript引用
'JavaScript引用方法
'使用Google返回查询mqycn的结果:
'<script language="javascript" src="mqycn.asp?so=google&key=mqycn"></script>
'使用百度返回查询mqycn的结果:
'<script language="javascript" src="mqycn.asp?so=baidu&key=mqycn"></script>

'1、输入url目标网页地址,返回值getHTTPPage是目标网页的html代码
function getHTTPPage(url,netcode)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
tmp=bytesToBSTR(Http.responseBody,netcode)
getHTTPPage=Replace(tmp,"UTF-8","GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function

'2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

Function Baidu_Search(mqycn_key)
Dim mqycn_baidu,mqycn_ok,mqycn_rex
mqycn_baidu="http://www.baidu.com/baidu?word="
mqycn_ok=getHTTPPage(mqycn_baidu&mqycn_key,"GB2312")
set rex=new RegExp
rex.Pattern="<table.*<br>"
mqycn_ok=rex.execute(mqycn_ok)(0)
Baidu_Search=mqycn_ok
End Function


Function Google_Search(mqycn_key)
Dim mqycn_google,mqycn_ok,mqycn_rex
mqycn_google="http://www.google.cn/search?q="
mqycn_ok=getHTTPPage(mqycn_google&mqycn_key,"UTF-8")
set rex=new RegExp
rex.Pattern="<div id=res.*</div>                  <br clear=all>"
mqycn_ok=rex.execute(mqycn_ok)(0)
mqycn_ok=Replace(mqycn_ok,"/search?complete=1&","http://www.google.cn/search?complete=1&")
Google_Search=mqycn_ok

End Function

Dim mqycn_search,mqycn_key,mqycn_js
mqycn_key=Request.QueryString("key")
mqycn_search=Request.QueryString("so")
if mqycn_key="" then mqycn_key="苗启源"
if mqycn_search="baidu" then
mqycn_js=Baidu_Search(mqycn_key)
else
mqycn_js=Google_Search(mqycn_key)
End if
mqycn_js=Replace(mqycn_js,"""","\""")
mqycn_js=Replace(mqycn_js,chr(10),"")
mqycn_js=Replace(mqycn_js,"/","\/")
Response.write "document.write("""&mqycn_js&""")"
%>

 
2007年08月16日 22:06

Mouse events

See also the key to my compatibility tables.

  
Event Explorer 5 Windows Explorer 6 Windows Explorer 5.2 Mac Mozilla 1.75 Safari 1.3 Opera 8 Netscape 4
click
The click event fires after one mousedown and one mouseup event have taken place on the same element.

Correct order:
  1. mousedown
  2. mouseup
  3. click

On links the event should also fire when the user tabs to the links and then hits Enter.
Test page document
Yes Yes Yes Yes Yes Yes Yes
document.onclick = doSomething;
Test page Link elements
Yes Yes Incomplete Yes Yes Yes Yes
document.links[0].onclick = doSomething;

  • In Explorer Mac, hitting Enter when the focus is on the link doesn't fire the click event.
  • Tabbing to a link is impossible in Opera and Safari. Officially the click event works fine, though, and the problem lies in the lack of Tab functionality.
Test page Any other element
Yes Yes Yes Yes Yes Yes Incomplete
x.onclick = doSomething;
where x is any HTML element
  • Netscape 4 does not count clicks on the text and requires captureEvents()
Test page Form fields
Yes Yes Incomplete Yes Almost Yes Incomplete
document.forms[0].elements[1].onclick = doSomething;
  • Safari fires the click event on a select box onblur
  • Netscape 4: Not on textareas and selects
  • Explorer Mac: Not on selects
Event Explorer 5 Windows Explorer 6 Windows Explorer 5.2 Mac Mozilla 1.75 Safari 1.3 Opera 8 Netscape 4
dblclick
The dblclick event fires after the user has clicked twice in rapid succesion on the same element. All browsers support it.
The incompatibilities are in the succession of events leading up to the dblclick. Every browser uses a different event order.

In practice it is not possible to use both the click and dblclick events on the same element. The browsers aren't sufficiently able to distinguish between them.
Test page Link element
Yes Yes Yes Yes Yes Yes Yes
document.links[0].ondblclick = doSomething;

The order of events leading up to the dblclick:
  • Explorer Windows: mousedown mouseup click mouseup dblclick
  • Explorer Mac: mousedown mouseup click mousedown dblclick
  • Mozilla: mousedown mouseup click mousedown mouseup click dblclick
  • Safari: mousedown mouseup click mousedown mouseup dblclick
  • Opera: mousedown mouseup click click dblclick mouseup
  • Netscape 4: mousedown mouseup mousedown mouseup dblclick
Test page Any element
Yes Yes Yes Yes Yes Yes Yes
x.ondblclick = doSomething;
where x is any HTML element
  • Netscape 4 requires captureEvents()
mousedown, mouseup
The mousedown event fires when the user depresses the mouse button.
The mouseup event fires when the user releases the mouse button.
If these two events take place on the same element, a click event fires.
Test page document
Yes Yes Yes Yes Yes Yes Yes
document.links[0].onmousedown = doSomething;
Test page Link element
Yes Yes Yes Yes Yes Yes Yes
document.links[0].onmousedown = doSomething;
Test page Any element
Yes Yes Yes Yes Yes Yes Yes
x.onmousedown = doSomething;
where x is any HTML element
  • Netscape 4 requires captureEvents()
mouseenter, mouseleave
The mouseenter and mouseleave events are subtly different from mouseover and mouseout. See the Mouse events page for an explanation of the differences.
mouseenter fires after mouseover, mouseleave before mouseout.
Test page Link element
5.5 Yes No No No No No
document.links[0].onmouseenter = doSomething;
Test page Any element
5.5 Yes No No No No No
x.onmouseleave = doSomething;
where x is any HTML element

I must admit I expected support by some minor browser when I included these Microsoft events in the test program.
Event Explorer 5 Windows Explorer 6 Windows Explorer 5.2 Mac Mozilla 1.75 Safari 1.3 Opera 8 Netscape 4
mousemove
The mousemove event fires whenever the user moves the mouse. It continues firing as long as the mouse moves.
Test page document
Yes Yes Yes Yes Yes Yes Yes
document.onmousemove = doSomething;
  • Netscape 4 requires captureEvents()
Test page Any element
Yes Yes Yes Yes Yes Yes Yes
x.onmousemove = doSomething;
where x is any HTML element
  • Netscape 4 requires captureEvents()
mouseover, mouseout
The mouseover event fires when the mouse enters the area of the element. The mouseout event fires when the mouse leaves the area again.
Test page Link element
Yes Yes Yes Yes Yes Yes Yes
document.links[0].onmouseover = doSomething;
Test page Any element
Yes Yes Yes Yes Buggy Yes Yes
x.onmouseout = doSomething;
where x is any HTML element
  • Safari fires separate events for mouseovers and -outs on the text contained by element x
  • Mozilla 1.2 did the same, but the bug was solved in 1.3

Form events

See also the key to my compatibility tables.

  
Event Explorer 5 Windows Explorer 6 Windows Explorer 5.2 Mac Mozilla 1.75 Safari 1.3 Opera 8 Netscape 4
change
The change event should fire immediately after any form element changes its state.

Text fields fire the event onblur when their content has changed.
Selects fire the event onclick at the moment of option selection.
Checkboxes and radio buttons should fire the event onclick
Test page Form fields
Almost Almost Almost Yes Incomplete Incomplete Incomplete
document.forms[0].elements[1].onchange = doSomething;
  • Checboxes and radios in Explorer fire the event onblur, which is too late.
  • Opera does not support this event on radios.
  • Netscape 4 does not support this event on checkboxes and radios.
  • Safari does not support this event on radios.
  • No browser fires the event after a reset has cleared all form fields.
reset
The reset event fires when the user resets the form.
Test page Form element
Yes Yes Yes Yes Yes Yes Yes
document.forms[0].onreset = doSomething;
select
The select event fires when the user has selected text in a text field. It should fire onmouseup, when the user finishes selecting.
Test page Form fields
Alternative Alternative Yes Yes No Yes No
document.forms[0].elements[1].onselect = doSomething;
  • Explorer Windows fires the event whenever any character is added to or removed from the selection
submit
The submit event fires when the user submits the form. It does not fire when a script submits the form (document.forms[0].submit()).
Test page Form element
Yes Yes Yes Yes Yes Yes Yes
document.forms[0].onsubmit = doSomething;

Key events

See also the key to my compatibility tables.

  
Event Explorer 5 Windows Explorer 6 Windows Explorer 5.2 Mac Mozilla 1.75 Safari 1.3 Opera 8 Netscape 4
keydown, keypress, keyup
keydown and keypress keep firing continuously as long as the user keeps a key depressed. keyup fires once when the user releases the key.

In Netscape 4 the keydown event fires only once, when the user initially depresses the key. In all other browsers there is no difference between keydown and keypress.

Test page Document
Yes Yes Yes Yes Yes Yes Yes
document.onkeydown = doSomething;
Test page Form fields
Yes Yes Yes Yes Yes Yes Yes
document.forms[0].elements[1].onkeydown = doSomething;
Support on text fields is enough to merit a Yes.

If you want to prevent the default action (ie: prevent the character from being inserted), you must use the keypress event.

Miscellaneous events

See also the key to my compatibility tables.

  
abort
The abort event fires when the user aborts the loading of images or the page.
It's very hard to create tests for the abort event. I'd need a test file of 12.5 Meg, to make sure that even on a fast 10 Mb/sec connection the user of the test has about 10 seconds to realize that to test the abort event he should stop the downloading and then to actually do it.

Besides the event is completely useless. I never needed it myself, nor did I ever encounter any site that uses it.

Just forget abort.
Event Explorer 5 Windows Explorer 6 Windows Explorer 5.2 Mac Mozilla 1.75 Safari 1.3 Opera 8 Netscape 4
error
The error event fires when a JavaScript error has occurred (window) or when a image cannot be found (img elements).
Test page window
? ? ? ? ? ?
window.onerror = doSomething;

The event test now fails in all browsers on all levels. That's odd, because I'm pretty sure it used to work.
Test page Image element
Yes Yes Yes Yes Yes Yes Yes
<img src="404.gif" onerror="doSomething()">

It's best to use inline event registration for this event because the error event may fire before the page has completely loaded, in which case an event handler registered onload wouldn't capture it.
DOMSubtreeModified
The DOMSubtreeModified event of an element fires whenever any change occurs in the node tree of the descendants of the element.
Test page Any element
No No No No No No No
x.addEventListener('DOMSubtreeModified',doSomething,false);
where x is any HTML element

This is the most general of W3C's DOM events, and the only one I test for now. Note that the use of the W3C event registration model is required.

 
2007年08月16日 22:06

Event Explorer 5 Windows Explorer 6 Windows Explorer 5.2 Mac Mozilla 1.75 Safari 1.3 Opera 8 Netscape 4
blur, focus
The blur event fires when an element loses focus.
The focus event fires when an element gains focus.

On a window, these events usually also fire when the window loses or gains focus because another element like a form field or a link gains or loses focus.

If the user clicks on a link, the link gains the focus and keeps it until another element gains the focus.

Curiously, W3C has never recognized the existence of these events on windows.
Test page window
Yes Yes Yes Buggy Yes Yes Yes
window.onfocus = doSomething;
  • In Mozilla hiding and showing the window fires both events three times. Clicking on the window also fires the focus event.
    If it must work perfectly in Mozilla and you don't care about Netscape 4, use document.body.onfocus.
Test page Link element
Yes Yes Incomplete Incomplete Incomplete Incomplete No
document.links[0].onblur = doSomething;

A perfect implementation would allow focusing and blurring both by a click on the link and by TABbing to the link.
Opera only supports the click; Mozilla, Safari and Explorer Mac only the TAB.
Note that in Safari you explicitly have to switch on tabbing to links in the Advanced preferences panel.
Test page Form fields
Yes Yes Yes Yes Incomplete Yes Yes
document.forms[0].elements[1].onblur = doSomething;
  • Safari supports these events only on text elements.
contextmenu
The contextmenu event fires whenever the user calls up a context menu.
Test page document
Yes Yes No Yes Yes No No
document.oncontextmenu = doSomething;
Event Explorer 5 Windows Explorer 6 Windows Explorer 5.2 Mac Mozilla 1.75 Safari 1.3 Opera 8 Netscape 4
load
The load event fires when an HTML document has been loaded completely, including all images, and arrays such as document.images have been initialized. You should run your own initializing scripts onload.
Test page window
Yes Yes Yes Yes Yes Minimal and alternative Yes
window.onload = doSomething;
  • Opera is being obnoxious
    The event does not fire when the user uses Back or Forward (see unload)
    Besides, it does not see <body onload> and window.onload as the same event; test it here.
    This code:
    window.onload = doSomething1;
    <body onLoad="doSomething2()">
    should only execute doSomething2(), because the earlier onload is overwritten by the later one. However, Opera executes both scripts.
    Opera itself says this is the correct way to handle onload. Although this may be true, it will certainly cause compatibility problems.
resize
The resize event fires while the user resizes the browser window. A major resize job causes the event to fire many times over
Test page window
Yes Yes Yes Alternative Yes Yes Buggy until 4.5
window.onresize = doSomething;
  • Mozilla fires the event once after the user has stopped resizing the window.
  • It seems that Explorer Windows on Win98 fires the event only twice, after the resizing has stopped. On XP it fires continuously.
  • In early Netscape 4's (until about 4.5) the resize event also fires when a page has finished loading, just after the load event.
Event Explorer 5 Windows Explorer 6 Windows Explorer 5.2 Mac Mozilla 1.75 Safari 1.3 Opera 8 Netscape 4
scroll
The scroll event fires when the user scrolls a page, a frame or an element with overflow: auto in any way supported by the browser: by using the scrollbar, the arrow keys or the mouse wheel.
Test page window
Yes Yes Yes Minimal Yes Yes No
window.onscroll = doSomething;
  • Mozilla only fires the event when the user uses the scrollbar. Since you cannot be certain to capture a scroll event, I judge its support Minimal, not Incomplete.
Test page element with overflow: auto
Yes Yes Yes Yes Yes No Untestable
x.onscroll = doSomething;
where x is an element with overflow: auto
  • Netscape 4 doesn't support overflow: auto
unload
The unload event fires whenever the page is unloaded for whatever reason.
It is not possible to distinguish between the user going to another page and the user closing the entire window, the unload event always fires. It is also not possible to cancel the unloading of the page.
Test page window
Yes Yes Yes Yes Yes Minimal Yes
window.onunload = doSomething;
  • In Opera load and unload do not fire when the user uses Back or Forward to enter or leave a page, or when the user closes the window.
    This severely hampers the usefulness of the events. When I write a load or unload script to, for instance, adjust the navigation of this site, I want it to run whenever the user enters or leaves the page, and not just when a browser thinks it's appropriate.
    Therefore I judge Opera's support Minimal and not Incomplete.
  • Safari 1.3 hardly ever fires the unload event, although it works fine in 1.2 and 1.3.1

 
     
 
 
RSS订阅
 
   
 
威客,在家也可以赚钱
 
 
 
 
 
 
 
 
     
 
个人档案
 
mqycn
男, 22岁
山东 济南 
上次登录:
7天前
加为好友
 
   
 
文章分类
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
     
 
最新评论
 
文章评论|照片评论


不错,我还没这么彻底的拆过8870呢
 

..
 

谢谢了,明白 了
 

7uyt
 

[表情]
 
     
 
好友最新文章
 
     
 
最近访客
 
 

穿着棉袄X澡

renyg8899

sunluyouwansui

xclzq

cbaq0832

aisiyour

Haidtu

寂调
     
 
背景音乐
 
 
订阅我的空间
 
已有人次访问本空间
 
订阅RSS  什么是RSS?

您也想拥有这样的空间?请点此申请。
     


©2009 Baidu