我正在尝试为慈善网站创建一个浮动按钮,以鼓励人们“捐赠”。想法是,向下滚动按钮时,该按钮在所有页面上始终保持可见。我创建了一个可以使用w3schools工具运行的按钮,但无法在新的Google网站(该网站是内置网站)上运行的。如果我将其嵌入,它将按钮放置在iFrame中,而不是在主站点上。 我希望创建一个google脚本可以允许我添加它,但是不知道从当前代码转换为google脚本的起点。非常感谢收到任何建议!
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
}
#myBtn {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
font-size: 18px;
border: none;
outline: none;
background-color: #660000;
color: white;
cursor: pointer;
padding: 15px;
border-radius: 4px;
}
#myBtn:hover {
background-color: #660066;
}
</style>
</head>
<body>
<button onclick="topFunction()" id="myBtn" title="Donate">Donate</button>
<div style="background-color:lightgrey;padding:30px 30px 2500px">Wibble.</div>
<script>
//Get the button
var mybutton = document.getElementById("myBtn");
mybutton.style.display = "block";
// When the user scrolls down 20px from the top of the document, show the button
//window.onscroll = function() {scrollFunction()};
//function scrollFunction() {
// if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
// mybutton.style.display = "block";
// } else {
// mybutton.style.display = "block";
// }
//}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
window.open("https: TARGET DONATION SITE");
}
</script>
</body>
</html>
答案 0 :(得分:1)
目前,可以将Google Apps脚本网络应用嵌入到新的Google协作平台网页中,但这就是所有可以完成的事情。
换句话说,您要尝试做的事无法在新的Google协作平台上完成。