事件和形象 [英] events and image

查看:80
本文介绍了事件和形象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



小组,


长话短说,我是JavaScript的新手,已经开始不到3

周。我的问题是


1)我怎样才能创建一种当用户点击gif或...时的情况。

图像文件触发事件?


我所做的是:


测试图像:

< a href ="" name =" linkImg1"

onclick =" javascript :my_trker('''http://www.mywebsite.com/akohan'');" >

< img name = img1 src =" flower.gif" border = 0>

< / a>


问题是,当我点击此图片时,它会通过

功能,但页面更改为路径:
http:// www。 mywebsite.com/akohan 并显示我在那里的

文件的列表或目录!

2)是否可以在Javascript中创建新事件?如果是这样,当用户右键点击链接或图像时,我怎么能监视一个事件呢?


你的帮助将被用来。


amit。


Hi group,

Long story short, I''m new to JavaScript and have started it less than 3
weeks. My question is

1) how can I create a situation that when user clicks on gif or ...
image file an event get triggered?

what I have done is:

Testing image:
<a href="" name="linkImg1"
onclick="javascript:my_trker(''http://www.mywebsite.com/akohan'');" >
<img name=img1 src="flower.gif" border=0 >
</a>

the problem is that when I click on this image it goes thru the
function but then the page changes to the path:
http://www.mywebsite.com/akohan and shows a list or directory of the
files I have there!
2) Is it possible to create new events in Javascript? lf so, how can I
monitor an event when user does a right-click on a link or image?

Your help will be appreicated.

amit.

推荐答案

amit写道:
嗨组,

长话短说,我是JavaScript的新手,已经开始不到3周了。我的问题是

1)我怎样才能创建一种情况,当用户点击gif或...
图像文件时会触发一个事件?

我是什么做的是:

测试图像:
< a href ="" name =" linkImg1"
onclick =" javascript :my_trker('''http://www.mywebsite.com/akohan'');" >
< img name = img1 src =" flower.gif" border = 0>
< / a>

问题是,当我点击这个图像时,它会通过
函数,但页面会改变到路径:
http://www.mywebsite.com/akohan 并显示我在那里的文件列表或目录!
Hi group,

Long story short, I''m new to JavaScript and have started it less than 3
weeks. My question is

1) how can I create a situation that when user clicks on gif or ...
image file an event get triggered?

what I have done is:

Testing image:
<a href="" name="linkImg1"
onclick="javascript:my_trker(''http://www.mywebsite.com/akohan'');" >
<img name=img1 src="flower.gif" border=0 >
</a>

the problem is that when I click on this image it goes thru the
function but then the page changes to the path:
http://www.mywebsite.com/akohan and shows a list or directory of the
files I have there!




原因是:href =""。如果你想停止点击

,你需要在你的onclick上添加return false:

onclick =" doSomething();返回false


BTW,''javascript :''不需要onclick


- <对于所有构成的事实而言,最令人费解的解释是阴谋理论家最有可能相信的事情。

。安装

实际事实是可选的。



The reason for that is: href="". If you want to STOP the click from
going through, you need to add return false to your onclick:
onclick = "doSomething(); return false"

BTW, ''javascript:'' is not needed for onclick

--
"The most convoluted explanation that fits all of the made-up facts is
the most likely to be believed by conspiracy theorists. Fitting the
actual facts is optional."


amit在6/29/2006 4:36 PM说:
amit said the following on 6/29/2006 4:36 PM:
嗨组,

长话短说,我是JavaScript的新手,已经开始不到3周了。我的问题是

1)我如何创建一种情况,当用户点击gif或...
图像文件时,事件被触发?


< img onclick =" my_trker('''')" .....>

我所做的是:<测试图像:
< a href ="" name =" linkImg1"
onclick =" javascript :my_trker('''http://www.mywebsite.com/akohan'');" >
< img name = img1 src =" flower.gif" border = 0>
< / a>

问题是,当我点击这个图像时,它会通过
函数,但页面会改变到路径:
http://www.mywebsite.com/akohan 并显示我在那里的文件列表或目录!


因为你在那里用链接导航了。

2)是否可以在Javascript中创建新事件?如果是这样,当用户右键单击链接或图像时,如何监视事件?
Hi group,

Long story short, I''m new to JavaScript and have started it less than 3
weeks. My question is

1) how can I create a situation that when user clicks on gif or ...
image file an event get triggered?
<img onclick="my_trker('''')".....>
what I have done is:

Testing image:
<a href="" name="linkImg1"
onclick="javascript:my_trker(''http://www.mywebsite.com/akohan'');" >
<img name=img1 src="flower.gif" border=0 >
</a>

the problem is that when I click on this image it goes thru the
function but then the page changes to the path:
http://www.mywebsite.com/akohan and shows a list or directory of the
files I have there!
Because you navigated there with the link.
2) Is it possible to create new events in Javascript? lf so, how can I
monitor an event when user does a right-click on a link or image?




onmousedown,onmouseup和onclick


-

兰迪

comp.lang.javascript常见问题 - http://jibbering.com/faq &新闻组每周

暂时在: http:// members.aol.com/_ht_a/hikksnotathome/cljfaq/

Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/



onmousedown, onmouseup, and onclick

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/




谢谢Tony,


我感谢你的帮助。你能告诉我一个图像的格式是什么?可以点击的
标签?


以下标签是可点击的,但它没有通过名字和
文件的路径!


测试图像:

< a href ="" name =" linkImg1"

onclick =" javascript :my_trker('''http://www.mywebsite.com/akohan'');" >

< img name = img1 src =" flower.gif" border = 0>

< / a>


我需要传递一些信息,即路径,文件名到函数。

任何线索?


谢谢,

amit


Tony写道:

Thanks Tony,

I appreciate your help. can you tell me what is the format for a image
tag which is clickable?

The following tag is clickable but it doesn''t pass the name and path of
the file!

Testing image:
<a href="" name="linkImg1"
onclick="javascript:my_trker(''http://www.mywebsite.com/akohan'');" >
<img name=img1 src="flower.gif" border=0 >
</a>

I need to pass some information i.e path, filename to a function.
Any clue?

Thanks,
amit


Tony wrote:
amit写道:
嗨组,

长话短说,我是JavaScript的新手,已经开始不到3周了。我的问题是

1)我怎样才能创建一种情况,当用户点击gif或...
图像文件时会触发一个事件?

我是什么做的是:

测试图像:
< a href ="" name =" linkImg1"
onclick =" javascript :my_trker('''http://www.mywebsite.com/akohan'');" >
< img name = img1 src =" flower.gif" border = 0>
< / a>

问题是,当我点击这个图像时,它会通过
函数,但页面会改变到路径:
http://www.mywebsite.com/akohan 并显示我在那里的文件列表或目录!
Hi group,

Long story short, I''m new to JavaScript and have started it less than 3
weeks. My question is

1) how can I create a situation that when user clicks on gif or ...
image file an event get triggered?

what I have done is:

Testing image:
<a href="" name="linkImg1"
onclick="javascript:my_trker(''http://www.mywebsite.com/akohan'');" >
<img name=img1 src="flower.gif" border=0 >
</a>

the problem is that when I click on this image it goes thru the
function but then the page changes to the path:
http://www.mywebsite.com/akohan and shows a list or directory of the
files I have there!



原因是:href ="" ;.如果你想停止点击
,你需要在你的onclick上添加return false:
onclick =" doSomething();返回false

BTW,''javascript :''不需要onclick

-
最复杂的适合所有构成事实的解释是阴谋理论家最容易相信的。适合
实际事实是可选的。



The reason for that is: href="". If you want to STOP the click from
going through, you need to add return false to your onclick:
onclick = "doSomething(); return false"

BTW, ''javascript:'' is not needed for onclick

--
"The most convoluted explanation that fits all of the made-up facts is
the most likely to be believed by conspiracy theorists. Fitting the
actual facts is optional."






这篇关于事件和形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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