2016-10-08 9 views
1

スライダからボタンを設定して、折りたたみの下にスクロールし、外部の「話す」ボタンを表示して浮かせるようにします。あなたが下にスクロールすると、この 'let's talk'ボタンがあなたに続きます。このボタンをクリックすると、外部サイトに移動します。jQuery - ボトムからページへのボタンと外部サイトへのリンク

ここをクリックしてこのJavaScriptをクリックするとトップに移動しますが、これは外部サイトに移動します。このスクリプトを変更するには、いくつか参考にしてください。

jQuery(document).ready(function($){ 
 
    "use strict";// browser window scroll (in pixels) after which the "back to top" link is shown 
 
    var offset = 300, 
 
     //browser window scroll (in pixels) after which the "back to top" link opacity is reduced 
 
     offset_opacity = 1200, 
 
     //duration of the top scrolling animation (in ms) 
 
     scroll_top_duration = 700, 
 
     //grab the "back to top" link 
 
     $back_to_top = $('.cd-top'); 
 
    
 
    //hide or show the "back to top" link 
 
    $(window).scroll(function(){ 
 
     ($(this).scrollTop() > offset) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out'); 
 
     if($(this).scrollTop() > offset_opacity) { 
 
      $back_to_top.addClass('cd-fade-out'); 
 
     } 
 
    }); 
 
    
 
    //smooth scroll to top 
 
    $back_to_top.on('click', function(event){ 
 
     event.preventDefault(); 
 
     $('body,html').animate({ 
 
      scrollTop: 0 , 
 
      }, scroll_top_duration 
 
     ); 
 
    }); 
 
    
 
}); 
 

 
$('a[href^="#"]').on('click', function(event) { 
 
     var target = $(this.getAttribute('href')); 
 
     if(target.length) { 
 
      event.preventDefault(); 
 
      $('html, body').stop().animate({ 
 
       scrollTop: target.offset().top 
 
      }, 1000); 
 
     } 
 
    });

答えて

0

uがちょうど一番上のボタンにバックはちょうどそれがうまく動作します。この

$back_to_top.on('click', function(event){ 
    event.preventDefault(); 
    window.location.replace('http://www.yoursite.com'); 
}); 
+0

$back_to_top.on('click', function(event){ event.preventDefault(); $('body,html').animate({ scrollTop: 0 , }, scroll_top_duration ); }); 

を置き換える、別のページにあなたを取るしたい場合。ありがとうございますAshraful!喜んで – user6942346

+0

。だからあなたの問題を解決してansを受け入れ、upvoteすることを忘れないでください。 –

関連する問題