Javascript + Image + HREF 需要帮助 [英] Help needed in Javascript + Image + HREF
问题描述
在上面的代码中,我将一个 javascript onclick 方法附加到图像标签.当我单击图像并按回时,它应该返回到它来自的页面.相反,它停留在同一页面上.有什么办法可以避免这种情况吗?(可能设置其他内容而不是 href="#"
).我设置href="#"
的原因是为了让我的光标变成手,除此之外没有任何用处.
In the above code, I am appending a javascript onclick method to the image tag. When I click the image once and I press back, it should go back to the page it came from. Instead its staying on the same page. Is there any way I can avoid that? (probably set something else instead of href="#"
). The reason I set href="#"
is to make my cursor turn into hand, other than that it has no use.
这是在 Firefox 中发生的.在 IE 中它工作正常.
This is occuring in Firefox. In IE it works fine.
请帮忙.谢谢.
推荐答案
<a href="#"><img src="http://www.google.com/intl/en_ALL/images/logo.gif" onClick="alert('hi'); return false;"/></a>
如果您不想加载链接,则需要将 return false;
添加到您的 onclick 事件中.
you need add return false;
to your onclick events if you don't want to load the link.
这篇关于Javascript + Image + HREF 需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!