检测身体的OnClick事件上的元素? [英] Detect element on OnClick event of body?

查看:63
本文介绍了检测身体的OnClick事件上的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当触发BODY标记的OnClick

事件时,是否可以检测到页面上的位置?


Thx

解决方案

Noozer写道:

当OnClick
事件发生时,是否有可能检测到页面上的点击发生的位置BODY标签被解雇?




是的。您可以获得光标的x,y坐标或实际点击的元素

.


您想要哪个?


以下是有关查找点击位置的信息:


< URL:http://www.quirksmode.org/js/events_properties .html>

以下是有关元素位置的信息:


< URL:http://www.quirksmode.org/js/findpos .html>

填充你的靴子。


-

Rob





我收集你想要检测点击的孩子?

来自作为参数或事件传递的事件对象。对象,得到

..target for mozilla / opera或srcElement for IE / opera,yes Opera同时执行,

event.target/event.srcElement返回子项点击

evnet在父母身上。

function checkwho(ev){

obj =(window.external)? event.srcElement:ev.target;

// IE是唯一一个带window.external的浏览器

alert(obj.nodeName)

}

document.body.onclick = checkwho;

Danny


Danny写道:


我收集你想检测点击的孩子?
从作为参数或事件传递的事件对象。对象,获取mozilla / opera的目标或者IE / opera的srcElement,是的,Opera都做了,
event.target / event.srcElement返回点击的孩子一旦
evnet在父母身上。

function checkwho(ev){
obj =(window.external)? event.srcElement:ev.target;
// IE是唯一一个带窗口的浏览器。外部


如果打算查看''event''是否传递给这个函数,

逻辑上要做的就是检查一下,而不是你认为可能表示支持一个或另一个事件模型的某些属性。你可能

也想保持''obj''本地,似乎没有必要将它作为全球

变量:


function checkwho(ev){

ev = ev || window.event;

var obj = ev.target || ev.srcElement;

alert(obj.nodeName)
}
document.body.onclick = checkwho;




帖子中的时间戳表示您在他们回复的帖子前一天发送了他们的信息。你能检查一下你的系统时钟吗?

也许你的新闻服务器出了问题?

-

Rob


Is it possible to detect where on a page the click occurred when the OnClick
event of the BODY tag is fired?

Thx

解决方案

Noozer wrote:

Is it possible to detect where on a page the click occurred when the OnClick
event of the BODY tag is fired?



Yes. You can get the x,y coordinates of the cursor or a reference to
the element that was actually clicked on.

Which do you want?

Here is information on finding the location of a click:

<URL:http://www.quirksmode.org/js/events_properties.html>
Here is information on the position of an element:

<URL:http://www.quirksmode.org/js/findpos.html>
Fill yer boots.

--
Rob




I gather you want to detect the child clicked on?
From the event object passed as argument or the event. object, get the
..target for mozilla/opera or srcElement for IE/opera, yes Opera does both,
the event.target/event.srcElement returns the child clicked on once the
evnet is on the parent.
function checkwho(ev) {
obj=(window.external) ? event.srcElement : ev.target;
// IE is the only browser with window.external
alert(obj.nodeName)
}
document.body.onclick=checkwho;
Danny


Danny wrote:


I gather you want to detect the child clicked on?
From the event object passed as argument or the event. object, get the
.target for mozilla/opera or srcElement for IE/opera, yes Opera does both,
the event.target/event.srcElement returns the child clicked on once the
evnet is on the parent.
function checkwho(ev) {
obj=(window.external) ? event.srcElement : ev.target;
// IE is the only browser with window.external
If the intention is to see if ''event'' was passed to the function, the
logical thing to do is to check for that, not some property that you
think might indicate support for one event model or another. You might
also want to keep ''obj'' local, there seems no point in it being a global
variable:

function checkwho( ev ) {
ev = ev || window.event;
var obj = ev.target || ev.srcElement;
alert(obj.nodeName)
}
document.body.onclick=checkwho;



The timestamp in your posts indicates that you sent them a day before
the post that they respond to. Can you please check your system clock?
Maybe it''s an issue with your news server?
--
Rob


这篇关于检测身体的OnClick事件上的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆