JavaScript add a way to scroll through a form with a scroll bar _javascript tips

Source: Internet
Author: User

The example in this article tells you how to add a form to a scroll bar in JavaScript. Share to everyone for your reference, specific as follows:

Two ways to achieve this:

First type:

<script type=/"text/javascript/" >
function scrollimg () {
 var posx,posy;
 if (window.innerheight) {
 posx = Window.pagexoffset;
 Posy = Window.pageyoffset;
 }
 else if (document.documentelement && document.documentElement.scrollTop) {
 posx = Document.documentElement.scrollLeft;
 Posy = Document.documentElement.scrollTop;
 }
 else if (document.body) {
 posx = document.body.scrollLeft;
 Posy = Document.body.scrollTop;
 }
 var Ad=document.getelementbyid (/"ad/");
Ad.style.top= (posy+500) +/"px/";
Ad.style.left= (posx+500) +/"px/";
ad.style.left=/"90%/";
 settimeout (/"scrollimg ()/");
</script>
<div id=/"ad/" style=/"Position:absolute;background: #606060; width:100px;height:100px; border:1px dotted #000; line-height:100px;text-align:center; left:103px; top:911px;/"> This advertisement for lease </div>
<script type=/" text/javascript/">
scrollimg ();
</script>

The second type:

 

More readers interested in JavaScript-related content can view the site topics: "JavaScript Search Algorithm Skills Summary", "JavaScript animation effects and Skills summary", "JavaScript Error and debugging skills summary", " JavaScript data structure and algorithm skills summary, "javascript traversal algorithm and Skills summary" and "JavaScript Mathematical Computing Usage Summary"

I hope this article will help you with JavaScript programming.

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