Home Web Front-end JS Tutorial Code: findPosX and findPosY_Basics

Code: findPosX and findPosY_Basics

May 16, 2016 pm 07:23 PM
and

/**
 * Find the X position of an object, relative to the viewport
 * Code copied from quirksmode.org
 * @param obj Object to find x position for
 */
function findPosX(obj)
{
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curleft  = obj.offsetLeft
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft  = obj.x;
  return curleft;
}

/**
 * Find the Y position of an object, relative to the viewport
 * Code copied from quirksmode.org
 * @param obj Object to find y position for
 */
function findPosY(obj)
{
  var curtop = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curtop  = obj.offsetTop
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
    curtop  = obj.y;
  return curtop;
}

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)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months 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)

ASUS motherboard options compatible with R55600 (including R55600u and 5600h) ASUS motherboard options compatible with R55600 (including R55600u and 5600h) Jan 02, 2024 pm 05:32 PM

Which ASUS motherboard should be paired with the R55600? The ASUS ROGStrixB550-FGaming motherboard is an excellent choice. It is perfectly compatible with Ryzen55600X processor and provides excellent performance and features. This motherboard has a reliable power supply system, can support overclocking, and provides a wealth of expansion slots and ports to meet daily use and gaming needs. ROGStrixB550-FGaming is also equipped with high-quality audio solutions, fast network connections and reliable heat dissipation design to ensure that the system remains efficient and stable. In addition, this motherboard adopts a gorgeous ROG style and is equipped with gorgeous RGB lighting effects, adding visual enjoyment to your computer. All in all, ASUS ROGStri

Which one is better, Celeron g4900 or i36100? (Which one is better, Celeron g4900 or i34170?) Which one is better, Celeron g4900 or i36100? (Which one is better, Celeron g4900 or i34170?) Jan 01, 2024 pm 06:01 PM

Which one is better, Celeron g4900 or i36100? When it comes to the two processors Celeron G4900 and I36100, there is no doubt that the performance of I36100 is superior. Celeron processors are generally considered low-end processors and are primarily used in budget laptops. The I3 processor is mainly used for high-end processors, and its performance is very good. Whether you are playing games or watching videos, you will not experience any lagging when using the I3 processor. Therefore, if possible, try to buy Intel I-series processors, especially for desktop computers, so that you can enjoy the fun of the online world. How is the performance of the Celeron G4900T? From a performance perspective, the Pentium G4900T performs well in terms of frequency. Compared with the previous version, the CPU performance is

Which one is better, Huntkey s980 or Bauhaus (Huntkey Apollo or Lianli Bauhaus o11) Which one is better, Huntkey s980 or Bauhaus (Huntkey Apollo or Lianli Bauhaus o11) Jan 12, 2024 am 11:06 AM

Which one is better, Huntkey s980 or Bauhaus? Huntkey S980 and Bauhaus (BeQuiet) are two different brands of computer power supply (PSU) manufacturers. Which one is better to choose depends on your needs and personal preferences. It has been recognized and praised by consumers. Their products are widely used in personal computers, servers, industrial equipment and other fields. Huntkey is committed to providing high-quality power products and constantly introducing new technologies and innovative designs. Their products undergo strict quality control and testing to ensure they can power devices stably and efficiently. Huntkey also pays attention to environmental protection and energy conservation, and strives to reduce its impact on the environment. Their power supplies comply with international standards and have received multiple certifications and awards. As a reputable brand

How to turn off the mouse and keyboard lights after turning off the Gigabyte motherboard GA78LMTS2? (The mouse light cannot be turned off after the Gigabyte a88 motherboard is shut down) How to turn off the mouse and keyboard lights after turning off the Gigabyte motherboard GA78LMTS2? (The mouse light cannot be turned off after the Gigabyte a88 motherboard is shut down) Dec 26, 2023 pm 07:58 PM

How to turn off the mouse and keyboard lights when Gigabyte motherboard GA78LMTS2 is turned off? For help, please check whether there is "Deeppoweroffmode" in the BIOS, that is, deep power-down mode. This option is located in the Power settings option of the BIOS. If this option is set to enabled, the device will not light up after shutting down the computer. The differences between Gigabyte motherboard DLED and LED are as follows: 1. Different positions: direct-type DLED is behind the LCD panel, and the LED lights are arranged in a matrix; side In-type LED installs the LED lights at the frame of the panel so that the light source shines out from the side. 2. Energy saving: Side-in LED TVs save more power than direct-type DLED TVs. The difference between DLED and LED is that DLED

Find maximum sum of two array elements in Java Find maximum sum of two array elements in Java Sep 11, 2023 pm 02:13 PM

Twoelementsgivingthemaximumsuminanarraymeans,wehavetofindtwolargestarrayelementswhichwilleventuallygivethemaximumsumpossible.InthisarticlewewillseehowwecanfindthemaximumsumoftwoelementsinJava.ToshowyousomeinstancesThe Chinese translation of Instance-1 is: Example-1Supposewehaveth

Tokens to be listed: $DOGEL, $BRAIN, $BTD, $PINU and $PIMEME Tokens to be listed: $DOGEL, $BRAIN, $BTD, $PINU and $PIMEME Mar 03, 2025 pm 08:03 PM

The cryptocurrency market continues to develop, bringing investors a growing investment opportunity. The listing of new coins has always attracted much attention, and February 2025 is the month when new coins are crowded, providing investors with a wide range of choices. Cryptocurrencies to watch in February 2025: Potential projects that cannot be missed This article will focus on five cryptocurrency projects that will be launched in February, and whether you are an experienced investor or a newbie, you can find the projects you are interested in. They are DogeLife ($DOGEL), DistriBrain ($BRAIN), Bitcoin USD ($BTD), PiINU ($PINU) and PIMEME ($PIMEME). Please be prepared and put these days

Written in C++, find a pair of numbers in a matrix with a given sum Written in C++, find a pair of numbers in a matrix with a given sum Sep 09, 2023 pm 06:05 PM

In this article, we will discuss the program to find pairs with a given sum in a given matrix. For example -Input:matrix[n][m]={ {4,6,4,65}, {56,1,12,32}, {4,5,6,44}, {13,9,11, 25}},SUM=20Output:Pairexists.Explanation:Sum=20isequaltothesumofnumbers9an

The sum of the products of each pair The sum of the products of each pair Sep 11, 2023 pm 07:33 PM

The pairwise product of the set X={a,b,c} can be defined as the sum of the products of all possible set pairs. The pairs of sets are Y={a*a,a*b,a*c,b*b,b*c,c*c}, where the products are commutative. Therefore, the pairwise product of set X is the sum of the elements of set Y, which is aa+ab+ac+bb+bc+cc. In mathematical terms, the sum of possible pairwise products can be expressed as: $$\mathrm{\displaystyle\sum\limits_{i=1,j=i}^{i\leqn,j\leqn}\:(i, j)=i\timej}$$Problem StatementGiven a number n. In the range (1, n), including n and 1, find

See all articles