HTML JSに戻り、共有ボタンを作成


2種類以上です.HTMLファイル間でWebページを共有する場合
  • 「戻る」ボタンでJSを使用してコードを記述します.
  • 「共有」ボタンでJSを使用してコードを記述します.

  • Javascript「戻る」headで作成します。

     <script>
           function back(){
           let url = window.location.href;
           let new_url = url.split('result.html')[0] + 'index.html';
            window.location.href= new_url;
            }
    </script>

    Javascript「共有」headで作成します。

       <script>
       function share(){
            var t = document.createElement("textarea");
                document.body.appendChild(t);
                t.value = window.location.href;
                t.select();
                document.execCommand('copy');
                document.body.removeChild(t);
                alert('복사 완료!')
            }
      </script>
    終了:)