标签:style blog http color io os java ar strong
一个AJAX实例
function xy_get(){
var url="http://prog.kehui.net:82/958game/small.php?op=jiaoyi&fi=stall&action=npcXY&cID="+sceneId;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//像html表单那样post数据 必须加上这个
xmlHttp.send();
xmlHttp.onreadystatechange=function(){ //onreadystatechange是引用函数的指针 可以是(匿名函数 ) 也可以是 (声明好的函数)
if(xmlHttp.readyState==4)
if(xmlHttp.status==200||xmlHttp.status==0){
xy = xmlHttp.responseText.split(",");
}
}
}
Ajax执行需要时间,在程序中应该充分考虑,比如,函数中用到在数据库取的Ajax数据如果考虑不充分,Ajax和函数一起执行,有可能函数执行完了Ajax还没执行完成。
js延时:
用JS
function xxx(){
}
setTimeout("xxx()",10000);--10s
http://www.w3school.com.cn/jsref/met_win_settimeout.asp
window.clipboardData.setData(‘text‘,html);复制到剪切板(仅支持IE,目前还不知道怎么用全兼容的方法)
清除浮动的两种方式:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cssTest</title>
<meta name="author" content="joh" />
<!-- Date: 2014-09-03 -->
<style type="text/css">
body { font-size:24px; color:red; }
#layout { background:#FF0; overflow:auto; zoom:1; }
#left { float:left; width:20%; height:200px; background:#CCC; }
#right { float:right; width:30%; height:80px; background:#CCC; }
</style>
</head>
<body>
<div id="layout">
<div id="left">Left</div>
<div id="right">Right</div>
</div>
<!-- <style type="text/css">
body { font-size:24px; color:red; }
#layout { background:#FF0; }
#left { float:left; width:20%; height:200px; background:#CCC; }
#right { float:right; width:30%; height:80px; background:#CCC; }
.clr { clear:both; }
</style> -->
<!-- <div id="layout">
<div id="left">Left</div>
<div id="right">Right</div>
<div style="clear:both"/>
</div> -->
</body>
</html>
http://blog.csdn.net/JeamKing/article/details/5617088backgroundPosition讲解(很好很强大)
e=arguments.callee.caller.arguments[0] || window.event || event ;js获得事件
mysql_num_rows($result)判断查询返回的行数 php中
if(target.nodeName.toLowerCase() == ‘table‘)或者 if(target.nodeName.toLowerCase() == ‘td‘) 获得点击对象
一个时钟练习:
<!DOCTYPE html>
<html>
<body>
<script>
function showTime(){
var myTime=geShiHua(new Date());
var myHours=geShiHua(myTime.getHours());
var myMinutes=geShiHua(myTime.getMinutes());
var mySeconds=geShiHua(myTime.getSeconds());
document.body.innerHTML=myHours+":"+myMinutes+":"+mySeconds;
}
function geShiHua(mytime){
if(mytime<=9){
mytime="0"+mytime;
}
return mytime;
}
var xianshi=setInterval(showTime,1000);
function qingchu(){
window.location.reload();
}
setTimeout(qingchu,3000);
</script>
</body>
</html>
javascript类,面向对象http://www.ruanyifeng.com/blog/2012/07/three_ways_to_define_a_javascript_class.html
http://howtonode.org/object-graphs-2
<script type="text/javascript">
function lei(){
this.tanchu=function(a){
alert(a);
}
}
var test=new lei();
test.tanchu("a");
</script>
var Cat = {
name: "大毛",
makeSound: function(){ alert("喵喵喵"); }
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////
标签:style blog http color io os java ar strong
原文地址:http://www.cnblogs.com/lixinyuan1213/p/3979968.html