GetSimple Support Forum
Smooth CSS movement problem [SOLVED] - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: Smooth CSS movement problem [SOLVED] (/showthread.php?tid=7864)



Smooth CSS movement problem [SOLVED] - lakaroth - 2016-01-20

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.


RE: Smooth CSS movement problem - lakaroth - 2016-01-20

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>