0
Chromeの現在のタブ(Facebook)をスクロールするボタンを追加したいが、コードを追加するとスクロールのアイコンが機能しなくなるが、試してみるとw3schoolエミュレータでは動作します。クロムの現在のタブにhtmlを追加できない
私はそれをした後、ウェブサイトを開くたびにどのようにそれが維持されるのでしょうか?私は最終的に成功する
コード
<html>
<head>
<style>
#myBtn {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
border: none;
outline: none;
background-color: red;
color: white;
cursor: pointer;
padding: 15px;
border-radius: 10px;
}
#myBtn:hover {
background-color: #555;
}
</style>
</head>
<body>
<button onclick="topFunction()" id="myBtn" title="Go to top">Scroll</button>
<script>
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
document.getElementById("myBtn").style.display = "block";
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
window.scrollBy(0,100);
}
</script>
</body>
</html>
どのようにこのコードを追加していますか?あなたが訪問したすべてのウェブサイトに新しいコードを注入しようとしているのであれば、ブラウザの拡張機能を構築する必要がありますが、これはもちろん可能ですが単純ではありません。 –
@DanielBeckあなたがブラウザエクステンションを構築すると言ったように私は、ページ上にボタンを作り、ページをスクロールさせる方法を知る必要がありました。 –
OK。これは単なるスタンドアロンのWebページをコーディングするよりはるかに複雑です。ここから始め、その問題に固有の質問を残しておけば、https://developer.chrome.com/extensions/getstarted –