Home Web Front-end JS Tutorial JavaScript method to add scrolling form with scroll bar_javascript skills

JavaScript method to add scrolling form with scroll bar_javascript skills

May 16, 2016 pm 03:14 PM
javascript scroll bar

The example in this article describes how to add a scrolling form with a scroll bar in JavaScript. Share it with everyone for your reference, the details are as follows:

Two implementation methods:

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()/",100);
}
</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;/">此广告位招租</div>
<script type=/"text/javascript/">
scrollImg();
</script>

Copy after login

Second type:

<html>
<head>
 <meta http-equiv=/"Content-Type/" content=/"text/html; charset=gb2312/">
 <title>Drag and Drop example</title>
 <script language=/"javascript/">
function picsize(obj,MaxWidth){
img=new Image();
img.src=obj.src;
if (img.width>MaxWidth)
{
 return MaxWidth;
}
else
{
 return img.width;
}
}
function CloseQQ()
{
divStayTopleft.style.display=/"none/";
return true; 
}
var online= new Array();
 </script>
</head>
<body>
 <div id=/"divStay/" style=/"position: absolute/">
 <table cellspacing=/"0/" cellpadding=/"0/" width=/"100%/" border=/"0/">
  <tbody>
  <tr>
   <td valign=/"top/" width=/"7%/">
   </td>
  </tr>
  </tbody>
 </table>
 </div>
 <div id=/"divStayTopleft/" style=/"position: absolute/">
 <table cellspacing=/"0/" cellpadding=/"0/" width=/"109/" border=/"0/">
  <tr>
  <td colspan=/"3/">
   <a onclick=/"CloseQQ()/" href=/"javascript:;/" shape=/"circle/" coords=/"91,16,12/">
   <img height=/"34/" src=/"images/qq_top.gif/" width=/"109/" usemap=/"#Map/"
    border=/"0/"></a></td>
  </tr>
  <tr>
  <td width=/"6/">
   <img height=/"100/" src=/"images/qq_life.gif/" width=/"6/"></td>
  <td valign=/"top/" width=/"96/" background=/"sto/qq_bg.gif/">
   <table cellspacing=/"0/" cellpadding=/"0/" width=/"90/" align=/"center/" border=/"0/">
   <tr>
    <td height=/"30/">
    <table cellspacing=/"0/" cellpadding=/"0/" width=/"90/" border=/"0/">
     <tr>
     <td>
      <img height=/"13/" src=/"images/qq_ico1.gif/" width=/"16/"><span
      class=/"font_12/"> <span style=/"font-size: 9pt/">客户服务</span></span></td>
     </tr>
    </table>
    </td>
   </tr>
   <tr>
    <td>
    <table border=/"0/" width=/"100%/" cellpadding=/"2/" id=/"table47/">
     <tr>
     <td width=/"15/" valign=/"top/" height=/"23/">
      <img border=/"0/" src=/"images/qq_v01.gif/" width=/"16/" height=/"16/"></td>
     <td valign=/"bottom/">
      <script>document.write(/"<a target=blank href=tencent://message/&#63;uin=178010108&Site=脚本之家&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa&#63;p=1:615050000:10 alt=[脚本之家]></a>/");</script>
     </td>
     </tr>
    </table>
    </td>
   </tr>
   <tr>
    <td>
    </td>
   </tr>
   <tr>
    <td>
    <table border=/"0/" width=/"100%/" cellpadding=/"2/" id=/"table1/">
     <tr>
     <td width=/"15/" valign=/"top/" height=/"23/">
      <img border=/"0/" src=/"images/qq_n01.gif/" width=/"16/" height=/"16/"></td>
     <td valign=/"bottom/">
      <script>document.write(/"<a target=blank href=tencent://message/&#63;uin=251922268&Site=网页特效&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa&#63;p=1:43486831:10 alt=[QQQQQ]></a>/");</script>
     </td>
     </tr>
    </table>
    </td>
   </tr>
   <tr>
    <td>
    </td>
   </tr>
   </table>
  </td>
  <td width=/"7/">
   <img height=/"100/" src=/"images/qq_right.gif/" width=/"7/"></td>
  </tr>
  <tr>
  <td colspan=/"3/">
   <img height=/"30/" src=/"images/qq_bottom1.gif/" width=/"109/"></td>
  </tr>
  <tr>
  <td colspan=/"3/">
   <img height=/"33/" src=/"images/qq_logo.gif/" width=/"109/"></td>
  </tr>
 </table>
 </div>
 <script type=/"text/javascript/">
function FloatTop()
{
var startX1 =document.body.offsetWidth-125 ,startY1 = 5;
var startX2 =0,startY2 = 95;
var ns = (navigator.appName.indexOf(/"Netscape/") != -1);
var d = document;
function ml(id,startX,startY)
{
var el=d.getElementById&#63;d.getElementById(id):d.all&#63;d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x;this.style.top=y;};
el.x = startX;
el.y = startY;
return el;
}
window.stayTopLeft=function()
{
var pY = ns &#63; pageYOffset : document.body.scrollTop;
ftlObj.y += (pY + startY1 - ftlObj.y)/8;
ftlObj1.y += (pY + startY2 - ftlObj1.y)/8;
ftlObj.sP(document.body.scrollLeft+document.body.offsetWidth-125, ftlObj.y);
ftlObj1.sP(ftlObj1.x, ftlObj1.y);
setTimeout(/"stayTopLeft()/", 30);
}
// ftlObj = ml(/"divStay/",document.body.scrollLeft+document.body.offsetWidth-125,0);
// ftlObj1 = ml(/"divStayTopLeft/",0,30);
ftlObj = ml(/"divStay/",(document.body.scrollLeft+document.body.offsetWidth)/2+379,0);
ftlObj1 = ml(/"divStayTopLeft/",(document.body.scrollLeft+document.body.offsetWidth)/2+379,30);
stayTopLeft();
}
FloatTop();
 </script>
</body>
</html>

Copy after login

Readers who are interested in more JavaScript-related content can check out the special topics on this site: "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation special effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm techniques", "Summary of JavaScript traversal algorithms and techniques" and "JavaScript Mathematics Summary of operation usage

I hope this article will be helpful to everyone in JavaScript programming.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to set the scroll bar to always show on Mac system - How to set the scroll bar to always show How to set the scroll bar to always show on Mac system - How to set the scroll bar to always show Mar 18, 2024 pm 06:22 PM

Recently, some friends have consulted the editor about how to set the scroll bar of the Mac system to always display. The following will bring you the method of setting the scroll bar of the Mac system to always display. Friends who need it can learn more. Step 1: In the system start menu, select the [System Preferences] option. Step 3: On the System Preferences page, select the [General] option. Step 3: On the general page, select [Always] to display scroll bars.

JavaScript and WebSocket: Building an efficient real-time weather forecasting system JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

How to use insertBefore in javascript How to use insertBefore in javascript Nov 24, 2023 am 11:56 AM

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

See all articles