摘要: 用CSS可以定义ul的自定义图标list-style:url(../images/sig1.jpg);在IE和FF下都能正常显示,但chrome不兼容。最好不要用这个属性,改为在li里定义背景图片:ul: list-style:none;li: background:url(../images/sig1.jpg) no-repeat; width:120px; 阅读全文
posted @ 2012-03-10 10:47 xngeer 阅读(252) 评论(0) 推荐(0)
摘要: //获取Cookie数组function getCookie(){ var array=new Array(); var cookies=document.cookie.split(/;/g); for(var i=0;i<cookies.length;i++){ var cookie=cookies[i]; if(cookie.indexOf("=")==-1){ continue; } var name=cookie.substring(0,cookie.indexOf("=")); ... 阅读全文
posted @ 2012-03-10 10:46 xngeer 阅读(467) 评论(0) 推荐(0)
摘要: 1. 添加。输入:元素,类名 function addClass(elm,newClass){ var classes = elm.className.split(' '); var classIndex=hasClass(elm,newClass); if(classIndex==-1)classes.push(newClass); elm.className = classes.join(' '); } 2. 查找。输入:元素,类名 返回:indexfunction hasClass(elm,className){ var classes = elm.... 阅读全文
posted @ 2012-03-10 10:45 xngeer 阅读(2823) 评论(0) 推荐(0)
摘要: 找下一兄弟节点的兼容问题:FF会将空白、换行等文本信息也当做childNodes中的一员,而IE则会忽略它们,只将DOM节点当做是childNodes的一员。function getNextNode(node){ node=typeof node=="string"?document.getElementById(node):node; var nextNode=node.nextSibling; if(!nextNode)return null; if(!document.all){ //FF不识别document.all while(true){ if(nextNode 阅读全文
posted @ 2012-03-10 10:44 xngeer 阅读(519) 评论(0) 推荐(0)
摘要: 输入:函数名function addLoadEvent(func){ var oldonload=window.onload; if("function"!=(typeof window.onload)){ window.onload=func; }else{ window.onload=function(){ oldonload(); func(); } }} 阅读全文
posted @ 2012-03-10 10:44 xngeer 阅读(190) 评论(0) 推荐(0)
摘要: function getEventTarget(e){ e=window.event||e; return e.srcElement||e.target;} 阅读全文
posted @ 2012-03-10 10:43 xngeer 阅读(334) 评论(0) 推荐(0)
摘要: function setAlphaOpacity(elm,value){ elm=typeof elm=="string"?document.getElementById(elm):elm; if(document.all){ //IE elm.style.filter='alpha(opacity='+value+')'; }else{ //FF elm.style.opacity=value/100; }} 阅读全文
posted @ 2012-03-10 10:43 xngeer 阅读(2907) 评论(0) 推荐(0)
摘要: function addEventHandler(elm,eventType,handler){ elm=typeof elm=="string"?document.getElementById(elm):elm; if(elm.attachEvent){ elm.attachEvent("on"+eventType,handler); }else if(elm.addEventListener){ elm.addEventListener(eventType,handler,false); }else return false;}//绑定事件 --解决 阅读全文
posted @ 2012-03-10 10:42 xngeer 阅读(712) 评论(0) 推荐(0)
摘要: function stopPropagation(e){ e=window.event||e; if(document.all){ e.cancelBubble=true; }else{ e.stopPropagation(); }}用法:document.getElementsByTagName("li")[0].onclick=function(e){ alert("li"); stopPropagation(e);} 阅读全文
posted @ 2012-03-10 10:42 xngeer 阅读(502) 评论(0) 推荐(0)
摘要: function isNumber(s){ return !isNaN(s);}function isString(s){ return "string"==typeof s;}function isBoolean(s){ return "boolean"==typeof s;}function isFunction(s){ return "function"==typeof s;}function isNull(s){ return s==null;}function isUndefined(s){ return "und 阅读全文
posted @ 2012-03-10 10:40 xngeer 阅读(883) 评论(0) 推荐(0)
摘要: 如:给ul下的li(或li下的XX)绑定事件<ul id="ul1"> <li><span>1</span></li> <li>2</li></ul><script type="text/javascript">function addEventHandler(elm,eventType,handler){ elm=typeof elm=="string"?document.getElementById(elm):elm; if 阅读全文
posted @ 2012-03-10 10:39 xngeer 阅读(1328) 评论(0) 推荐(0)
摘要: 用函数原型实现像java bean的效果function myApp(){ this.name="co2"; this.age=23;}myApp.prototype.getName=function(){ return this.name;}myApp.prototype.setName=function(name){ this.name=name;}var app=new myApp();alert("app.name:"+app.getName()); //co2app.setName("co22");alert("a 阅读全文
posted @ 2012-03-10 10:38 xngeer 阅读(1626) 评论(0) 推荐(0)
摘要: PHP substr strpos$pos=strpos("12345", "3");$substring=substr("12345", 0,$pos);echo $substring;输出:12JAVA subString indexofString str="12345";int pos=str.indexOf("3");String substring=str.substring(0, pos);System.out.println(substring);输出:12PHP 从最末一个&q 阅读全文
posted @ 2012-03-10 10:37 xngeer 阅读(194) 评论(0) 推荐(0)
摘要: 大体上这篇贴很简洁实用(本人喜欢把条条理理写的很漂亮的人,谢谢永福)转:PHP执行系统命令(简介及方法)在PHP中调用外部命令,可以用如下三种方法来实现:方法一:用PHP提供的专门函数(四个):PHP提供4个专门的执行外部命令的函数:exec(), system(), passthru(), shell_exec()1)exec()原型: string exec ( string $command [, array &$output [, int &$return_var ]] ) 说明: exec执行系统外部命令时不会输出结果,而是返回结果的最后一行。如果想得到结果,可以使用 阅读全文
posted @ 2012-03-10 10:37 xngeer 阅读(1442) 评论(0) 推荐(0)
摘要: 想看到函数返回的bool结果,但bool结果不能在浏览器输出怎么办?<?phpvar_dump(is_file('a_file.txt')) . "\n";var_dump(is_file('/usr/bin/')) . "\n";?>输出:bool(true)bool(false) 阅读全文
posted @ 2012-03-10 10:36 xngeer 阅读(2289) 评论(0) 推荐(0)
摘要: <?php $fileName=$_GET['file']; header('Content-type:application/force-download'); header('Content-Disposition:inline,filename='.$fileName); $fp=fopen("文件目录".$fileName, "r"); $content=fread($fp, filesize("文件目录".$fileName)); echo $content;?>/ 阅读全文
posted @ 2012-03-10 10:35 xngeer 阅读(237) 评论(0) 推荐(0)
摘要: 本函数可能理论上说有些不地道,把utf-8的中文字符和char一视同仁,都按长度为1计算function string_substring($string,$start,$length) { $countstart=0; $countlength=0; $printstring=""; for($i=0;$i<strlen($string);$i++) { while($countstart<$start) { $countstart++; if(ord(substr($string,$i,1))>128) { $i+=3; } else{ $i++; } 阅读全文
posted @ 2012-03-10 10:34 xngeer 阅读(482) 评论(0) 推荐(0)
摘要: PHP session 变量用于存储有关用户会话的信息,或更改用户会话的设置。Session 变量保存的信息是单一用户的,并且可供应用程序中的所有页面使用。理解:session用于单一用户与服务器的交互,每个用户的session都是不一样的。session作为全局变量,在浏览器开户期间所有页面内有效。Session 的工作机制是:为每个访问者创建一个唯一的 id (UID),并基于这个 UID 来存储变量。UID 存储在 cookie 中,亦或通过 URL 进行传导。在把用户信息存储到 PHP session 中之前,首先必须启动会话。注释:session_start() 函数必须位于 < 阅读全文
posted @ 2012-03-10 10:34 xngeer 阅读(194) 评论(0) 推荐(0)
摘要: php textarea中的换行符为"\r\n"不是'\n'不是"<br />"不是'\r\n'不是'\r'+'\n' 阅读全文
posted @ 2012-03-10 10:33 xngeer 阅读(693) 评论(0) 推荐(0)
摘要: function getConnection(){ @mysql_connect("localhost","username","password") or die("无法连接数据库"); @mysql_select_db("databasename") or die("未找到数据库"); }getConnection(); $query="select definition,accession,gi from birds_nucleotide order by d 阅读全文
posted @ 2012-03-10 10:32 xngeer 阅读(179) 评论(0) 推荐(0)