Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Smooth CSS movement problem [SOLVED]
#1
Hi guys, i'm trying to include a simple JQuery smooth movemente for anchor link, in my website with get simple.
I have convert a static page to a theme, it's strange my problem is this.

In the heaer i have add:


PHP Code:
       <script src="<?php get_theme_url(); ?>/js/jquery-1.4.1.min.js"></script> 


In order to include Jquery library.

In the template i have add this:


Code:
<script type="text/javascript">
   $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
 && location.hostname == this.hostname) {
 var $target = $(this.hash);
 $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
 if ($target.length) {
 var targetOffset = $target.offset().top;
 $('html,body').animate({scrollTop: targetOffset}, 1000);
 return false;}
 }
});
</script>


And in the CMS in the backend page WYSIWYG editor i have this:


Code:
<p><a href="#anchorlink">Go to anchor link</a> ...</p>

<h2><a name="anchorlink"></a>Section</h2>
<p>More contents bla bla bla</p>

In a static HTML page this work, but in my website no... go to the lin without smooth effect.

Where's the problem?

I use:
Xampp Local Server 1.8.3-4
OSX Mac
Browser: Firefox 43.04
Get simple version 3.3.2

Best
Lakaroth
Thank you.
Reply
#2
Solved Guys...
Sorry anyway maybe is useful for other user the correct code is this:


PHP Code:
<script type="text/javascript">
$(function() {
 
 $('a[href*=#]:not([href=#])').click(function() {
 
   if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
 
     var target = $(this.hash);
 
     target target.length target : $('[name=' this.hash.slice(1) +']');
 
     if (target.length) {
 
       $('html,body').animate({
 
         scrollToptarget.offset().top
        
}, 1000);
 
       return false;
 
     }
 
   }
 
 });
});
</script> 
Reply




Users browsing this thread: 1 Guest(s)