[英]href links only open on “right click in new tab”
I'm having trouble with some script interfering with my basic href links and not allowing them to open on left click. 我遇到了一些脚本干扰我的基本href链接,并且不允许它们在单击鼠标左键时打开的麻烦。
My url is http://www.mayabdesign.com , and on each specific project page (like http://www.mayabdesign.com/#cbp=ajax/sculptjax.html ) the "view the site" button does nothing unless you right click and open in a new tab. 我的网址是http://www.mayabdesign.com ,并且在每个特定的项目页面(例如http://www.mayabdesign.com/#cbp=ajax/sculptjax.html )上,“查看站点”按钮都没有作用,除非您右键单击并在新选项卡中打开。 I know the problem, but can't seem to figure out the solution.
我知道问题所在,但似乎无法找出解决方案。
Thanks in advance. 提前致谢。 :)
:)
Add click function to Dom Ready
将点击功能添加到
Dom Ready
$(document).ready(function(){
$("a").click(function( event ) {
if ( $(this).attr("href").match("#") ) {
event.preventDefault();
var href = $(this).attr('href').replace('#', '')
scrollToAnchor( href );
});
});
我认为点击事件被event.preventDefault()阻止了
This is the relevent code that is preventing the link from returning. 这是阻止链接返回的相关代码。 Since the href value does in fact math
#
its default action is prevented 由于href值实际上是数学
#
它的默认操作被阻止
$("a").click(function( event ) {
if ( $(this).attr("href").match("#") ) {
event.preventDefault();
var href = $(this).attr('href').replace('#', '')
scrollToAnchor( href );
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.