Jump to content

animate leaving a page code modification


ukscotth

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.