如何在HTML中调用javascript函数而不是href [英] How to call javascript function instead of href in HTML

查看:181
本文介绍了如何在HTML中调用javascript函数而不是href的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在html中有一些模型

I have some mockup in html

<a href="javascript:ShowOld(2367,146986,2)"><img title="next page" alt="next page" src="/themes/me/img/arrn.png"></a>

发送请求时,我收到了服务器的响应。

I got the response from server when I sent the request.

使用这个模型,我得到了一个ajax请求的响应,将我的代码发送到服务器。

With this mockup I got as a response of ajax request that sends my code to server.

嗯,一切都很好,但是当我点击链接浏览器想要打开的功能为链接;意思是点击后,我看到地址栏为

Well, everything is fine but when I click on the link the browser wants to open the function as link; meaning after click I see the address bar as

javascript:ShowOld(2367,146986,2)

意味着浏览器的东西是url,如果我想在firebug这样做的工作。现在我想这样做,然后当有人点击链接时,浏览器尝试调用DOM中已加载的功能,而不是尝试在浏览器中打开它们。

means browser thing that's url if I want to do this in firebug that's work. Now I want to do that then when anyone clicks the link then the browser tries to call the function already loaded in the DOM instead of trying to open them in browser.

推荐答案

该语法应该可以正常工作,但可以尝试这种方法。

That syntax should work OK, but you can try this alternative.

<a href="javascript:void(0);" onclick="ShowOld(2367,146986,2);">

<a href="javascript:ShowOld(2367,146986,2);">

这篇关于如何在HTML中调用javascript函数而不是href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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