input框 下面 紧跟着div弹出层,js取top left数值
来源:未知 责任编辑:责任编辑 发表时间:2013-11-26 22:14 点击:次
<form>
<input type="text" id="searchId" onkeyup="showSearch(this)" onblur="hideSearch(this)"/>
</form>
<div style="width:300px;height:500px;border:1px solid #817F82;display:none;position: absolute;" id="showInfo">
</div>
<script>
var setSearchFlag;
function showSearch(obj){
clearSearchFlag();
var w3c=(document.getElementById)? true:false;//w3c 标准
var ns6=(w3c && (navigator.appName=="Netscape"))? true: false;//Netscape浏览器 标准的W3C
var left,top;
if (!ns6){//判断IE
var nLt = 0;
var nTp = 0;
var offsetParent = obj;
while (offsetParent!=null && offsetParent!=document.body) {
nLt += offsetParent.offsetLeft;
nTp += offsetParent.offsetTop;
offsetParentoffsetParent=offsetParent.offsetParent;
}
left = nLt;
top = nTp + obj.offsetHeight;
} else {//标准w3c
left = obj.offsetLeft -5;
top = obj.offsetTop + obj.offsetHeight;
<input type="text" id="searchId" onkeyup="showSearch(this)" onblur="hideSearch(this)"/>
</form>
<div style="width:300px;height:500px;border:1px solid #817F82;display:none;position: absolute;" id="showInfo">
</div>
<script>
var setSearchFlag;
function showSearch(obj){
clearSearchFlag();
var w3c=(document.getElementById)? true:false;//w3c 标准
var ns6=(w3c && (navigator.appName=="Netscape"))? true: false;//Netscape浏览器 标准的W3C
var left,top;
if (!ns6){//判断IE
var nLt = 0;
var nTp = 0;
var offsetParent = obj;
while (offsetParent!=null && offsetParent!=document.body) {
nLt += offsetParent.offsetLeft;
nTp += offsetParent.offsetTop;
offsetParentoffsetParent=offsetParent.offsetParent;
}
left = nLt;
top = nTp + obj.offsetHeight;
} else {//标准w3c
left = obj.offsetLeft -5;
top = obj.offsetTop + obj.offsetHeight;
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>