Javascript + Image + HREF 需要帮助 [英] Help needed in Javascript + Image + HREF

查看:29
本文介绍了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屋!

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