Jump to content

Recommended Posts

Hi,

 

I have the following code which gives a fading out effect when clicking on links. I need to be able to disable it for anchor links so it is disabled when using # as the link.

 

Any ideas ? 

/* 
* Function to animate leaving a page
*/
$.fn.leavePage = function() {   
    
  this.click(function(event){

    // Don't go to the next page yet.
    event.preventDefault();
    linkLocation = this.href;
    
    // Fade out this page first.
    $('body').fadeOut(400, function(){
      
      // Then go to the next page.
      window.location = linkLocation;
    });      
  }); 
};

Thanks,

Scott.

Not sure I understood exactly what you meant, but I'm assuming a tag like this..

 

 

<a href="#">Link</a>

 

You do not want it to process the code?

 

If so, you could just wrap the current code inside the click eventhandler with an if-statement.

 

 

if(this.href !== '#') {
... //Your code here
}

 

Or matching it for cases like href="#/link/here">

 

 

if(this.href.indexOf('#') === -1) {
...//Your code here
}

 

If I missunderstood, just let me know.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.