简体   繁体   中英

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.

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. I know the problem, but can't seem to figure out the solution.

Thanks in advance. :)

Add click function to Dom Ready

$(document).ready(function(){
    $("a").click(function( event ) {
          if ( $(this).attr("href").match("#") ) {
          event.preventDefault();
          var href = $(this).attr('href').replace('#', '')
          scrollToAnchor( href );
    });
});

CHECK DEMO HERE

我认为点击事件被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

$("a").click(function( event ) {
      if ( $(this).attr("href").match("#") ) {
      event.preventDefault();
      var href = $(this).attr('href').replace('#', '')
      scrollToAnchor( href );
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM