如题
系统有没有这样的函数..??不要自己写的
谢谢
系统有没有这样的函数..??不要自己写的
谢谢
解决方案 »
- 新手求教~JS的基本问题(代码~)动动小手,100分到手·~·
- 程序控制光标在文本区域移动
- google广告FLASH超级连接怎么做的?
- js打印打印机没反应,请高手指点
- 关于同个exe多次运行的问题
- 怎么得到一个不重复的随机数组
- 帮忙看看,strvalue后面怎么写
- 帮忙看看。
- “var doc = top.treeFrame.window.document”这样的写法有错吗?为什么在本机正常,上传后就会报“top.treeFrame.window”不是对象的错??
- 求大神指导 这个错误怎么解决
- 急求可以根据星期几进行判断的自动切换代码,在线等
- 多层嵌套的iframe里面获取最底层iframe里某个元素相对顶层的坐标
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
<script type="text/javascript" language="javascript">
function isParent(obj,pobj){
do{
obj = obj.parentNode;
if(obj==pobj){
return true;
}
}while(obj.tagName!='BODY');
return false;
}
window.onload = function (){
alert(isParent($("d1"),$("t1")));//true
alert(isParent($("d1"),$("td1")));//false
}
function $(id){
return document.getElementById(id);
}
</script>
</head><body>
<table id="t1">
<tr>
<td>
<div id="d1"></div></td>
<td id="td1"></td>
</tr>
</table>
</body></html>
function contains(a, b){
return a.contains ?
a != b && a.contains(b) :
!!(a.compareDocumentPosition(b) & 16);
}解释请看这里http://ejohn.org/blog/comparing-document-position/
if (document.documentElement.compareDocumentPosition) return function(nodeA, nodeB){
return (nodeA.compareDocumentPosition(nodeB) & 16) == 16;
}
if (document.documentElement.contains) return function(nodeA, nodeB){
return nodeA.contains(nodeB) && nodeA != nodeB;
};
return function(nodeA, nodeB){
while (nodeB = nodeB.parentNode)
if (nodeB == nodeA) return true;
return false;
}
})();