a href =“#"链接到我的索引,而不是因为基本href而仅使用我想要的jquery函数 [英] a href="#" linking to my index instead of just using my desired jquery function because of base href
问题描述
我正在尝试使用一个要求href为href =#"的jquery插件.但是,当我单击这些具有onclick动作的链接时,索引页面将加载以下网址,而不是发生该动作(我可以看到它实际上是短暂发生的):www.mysite.com/#
I am trying to use a jquery plugin that requires the href to be href="#". however when I click on these links to which have onclick actions, then instead of the action taking place (I can see it take place briefly actually) the index page loads with the url: www.mysite.com/#
我已将问题缩小为购物车所需的基本href脚本:
I have narrowed the problem down to my base href script that is required for my shopping cart:
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>" />
需要此基本href脚本在SSL页面和无SSL页面之间切换. DIR_WS_CATALOG定义为/
This base href script is needed to switch between SSL and none SSL pages. DIR_WS_CATALOG is defined as /
这是我的索引..那么有什么办法解决呢?您是否需要更多信息,我不确定还要看什么?
which is my index.. So is there any way around this? Do you need more information I'm not sure what else to look at?
推荐答案
通常,我们会进行event.preventDefault();在锚点上. IE浏览器
Usually we do event.preventDefault(); on the anchor. IE
$('a.class').click(function(e) {
$(this).toggleClass('active');
e.preventDefault();
});
这篇关于a href =“#"链接到我的索引,而不是因为基本href而仅使用我想要的jquery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!