JavaScript emulates pop-up windows with div _ form scrolling follow _javascript tips

Source: Internet
Author: User

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http:// "> <ptml xmlns=" "lang=" ZH-CN "> <pead> <title> scrollable follow pop-up box effect code--cloud-dwelling community </title> <script> function getPosition () {var top = Document.documentElement.scrollTop; var left = Document.documentElement.scrollLeft; var height = document.documentElement.clientHeight; var width = document.documentElement.clientWidth; return {top:top,left:left,height:height,width:width}; function Showpop () {var width = 300;//popup width var height = 160;//popup height of var obj = document.getElementById ("Pop"); = "block"; = "absolute"; = "999"; = width + "px"; = height + "px"; var Position = getPosition (); Leftadd = (position.width-width)/2; Topadd = (position.height-height)/2; = ( + topadd) + "px"; Obj.stylE.left = (Position.left + leftadd) + "px"; Window.onscroll = function () {var Position = getPosition (); = ( + topadd) + "px"; = (Position.left + leftadd) + "px"; }; function Hidepop () {document.getElementById ("Pop"). Style.display = "None"; } </script> </pead> <body> Author: Ding Co-scrolling follow <div id= "Pop" >test<br>hide</div> <br& Gt;<br><br><br><br><br><br><br><br><br><br><br ><br><br><br><br><br><br><br><br><br><br><br ><br><br><br><br><br><br><br><br><br><br><br ><br><br><br><br> Show <br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br>< Br><br><br><br><br><br><br> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Related Article

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: 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.