HTML JSに戻り、共有ボタンを作成
4447 ワード
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>
終了:)Reference
この問題について(HTML JSに戻り、共有ボタンを作成), 我々は、より多くの情報をここで見つけました https://velog.io/@ghj616/HTML-JS-뒤로가기-공유하기-버튼-만들기テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol