aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/api/uievent/pagex/index.html
blob: fbd75e26f85143a62daa2ce09cfd555c5e1b514f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
title: event.pageX
slug: Web/API/UIEvent/pageX
tags:
  - DOM
  - Referencia_DOM_de_Gecko
  - Todas_las_Categorías
translation_of: Web/API/UIEvent/pageX
---
<p>{{ ApiRef() }}</p>
<h3 id="Sumario" name="Sumario">Sumario</h3>
<p>Retorna la coordena horizontal del evento, relativo al documento completo.</p>
<h3 id="Sintaxis" name="Sintaxis">Sintaxis</h3>
<pre class="eval"><i>pageX</i> =<i>event</i>.pageX;
</pre>
<p><code>pageX</code> es un valor entero expresado en pixels para la corrdenada X del puntero del ratón, relativo al documento entero, cuando se produjo el evento. Esta propiedad toma en cuenta la barra de desplazamiento horizontal de la página.</p>
<h3 id="Ejemplo" name="Ejemplo">Ejemplo</h3>
<pre>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;pageX\pageY &amp; layerX\layerY example&lt;/title&gt;

&lt;script type="text/javascript"&gt;

function showCoords(evt){
  var form = document.forms.form_coords;
  var parent_id = evt.target.parentNode.id;
  form.parentId.value = parent_id;
  form.pageXCoords.value = evt.pageX;
  form.pageYCoords.value = evt.pageY;
  form.layerXCoords.value = evt.layerX;
  form.layerYCoords.value = evt.layerY;
}

&lt;/script&gt;

&lt;style type="text/css"&gt;

 #d1 {
  border: solid blue 1px;
  padding: 20px;
 }

 #d2 {
  position: absolute;
  top: 180px;
  left: 80%;
  right:auto;
  width: 40%;
  border: solid blue 1px;
  padding: 20px;
 }

 #d3 {
  position: absolute;
  top: 240px;
  left: 20%;
  width: 50%;
  border: solid blue 1px;
  padding: 10px;
 }

&lt;/style&gt;
&lt;/head&gt;

&lt;body onmousedown="showCoords(event)"&gt;

&lt;p&gt;To display the mouse coordinates please click anywhere on the page.&lt;/p&gt;

&lt;div id="d1"&gt;
&lt;span&gt;This is an un-positioned div so clicking it will return
layerX/layerY values almost the same as pageX/PageY values.&lt;/span&gt;
&lt;/div&gt;

&lt;div id="d2"&gt;
&lt;span&gt;This is a positioned div so clicking it will return layerX/layerY
values that are relative to the top-left corner of this positioned
element. Note the pageX\pageY properties still return the
absolute position in the document, including page scrolling.&lt;/span&gt;

&lt;span&gt;Make the page scroll more! This is a positioned div so clicking it
will return layerX/layerY values that are relative to the top-left
corner of this positioned element. Note the pageX\pageY properties still
return the absolute position in the document, including page
scrolling.&lt;/span&gt;
&lt;/div&gt;

&lt;div id="d3"&gt;
&lt;form name="form_coords"&gt;
 Parent Element id: &lt;input type="text" name="parentId" size="7" /&gt;&lt;br /&gt;
 pageX:&lt;input type="text" name="pageXCoords" size="7" /&gt;
 pageY:&lt;input type="text" name="pageYCoords" size="7" /&gt;&lt;br /&gt;
 layerX:&lt;input type="text" name="layerXCoords" size="7" /&gt;
 layerY:&lt;input type="text" name="layerYCoords" size="7" /&gt;
&lt;/form&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<h3 id="Specificaci.C3.B3n" name="Specificaci.C3.B3n">Specificación</h3>
<p>No es parte del estándar público.</p>
<p>{{ languages( { "pl": "pl/DOM/event.pageX", "en": "en/DOM/event.pageX" } ) }}</p>