The input box is followed by the div pop-up layer. js takes the top left value.

Source: Internet
Author: User

<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 Standard
Var ns6 = (w3c & (navigator. appName = "Netscape "))? True: false; // W3C standard for the Netscape Browser
Var left, top;
If (! Ns6) {// judge 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 {// standard w3c
Left = obj. offsetLeft-5;
Top = obj. offsetTop + obj. offsetHeight;
}

Certificate ('{showinfo'}.css ('display', 'block ');
Certificate ('{showinfo'}.css ('top', top );

}
Function hideSearch (obj ){
SetSearchFlag = settimeout(function({{}('{showinfo'}.css ('display', 'None') ;}, 100 );
}

Function clearSearchFlag (){
Window. clearTimeout (setSearchFlag );
}

 
</Script>

From the wwwyuanliang10000 Column

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.