我在Google网站中对HTML有问题

发布于 2025-01-30 15:30:21 字数 524 浏览 4 评论 0原文

因为我不了解Google脚本,所以我使用Google站点,并且每当我尝试将此代码放入时,都没有发生任何事情,所以我使用了另一个代码,可以告诉我它是否不起作用,它说:“用户取消请求”,当您单击按钮时,将显示一个更新的下拉,并且应该出现即将到来的更新,但是什么也不会发生。

<button onclick="myFunction()">Press for Announcements</button>
<script>
function myFunction(){
  alert("New:\n- New Code\n- Update Button\n- About the Creator Section\n- Contact the Creator\n\nComing Soon:\n- Quote Code YouTube Channel\n- More Codes\n- Accounts\n- Commenting\n- Pre-made Code\n- C/C++\n- Code Sandbox");
}
</script>

Because I don't understand Google Scripts, I use Google Sites, and when ever I try put this code in, nothing happens, so I used another piece of code that would tell me if it wasn't working, and it said "User canceled request", when you click the button, a drop down of updates, and upcoming updates should appear, but nothing happens.

<button onclick="myFunction()">Press for Announcements</button>
<script>
function myFunction(){
  alert("New:\n- New Code\n- Update Button\n- About the Creator Section\n- Contact the Creator\n\nComing Soon:\n- Quote Code YouTube Channel\n- More Codes\n- Accounts\n- Commenting\n- Pre-made Code\n- C/C++\n- Code Sandbox");
}
</script>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖哒 2025-02-06 15:30:21

您的问题是您无法在Google站点中使用警报对话框。 Google脚本可能会令人困惑。打开网络控制台通常是一件好事,因为这些错误应该使您对正在发生的事情有所了解。

此更改将使您的文本添加到网站内的新DIV中。我想您希望它能做得更多,但希望这可以帮助您了解出了什么问题。

<button onclick="createHTMLalert()">Press for Announcements</button>
<script>

    function createHTMLalert(){
        if(!document.getElementById('announcements_alert')){
            let announcements_alert = document.createElement('div');
            announcements_alert.id = 'announcements_alert';
            document.body.appendChild(announcements_alert);
            announcements_alert.innerText = "New:\n- New Code\n- Update Button\n- About the Creator Section\n- Contact the Creator\n\nComing Soon:\n- Quote Code YouTube Channel\n- More Codes\n- Accounts\n- Commenting\n- Pre-made Code\n- C++ and C for Game Making\n- Quote Code Twitter Page\n- Code Park";
        }
    }
</script>

Your issue is that you are unable to use alert dialogs in Google Sites. Google Scripts can be confusing. It's usually good to open up the web console as these errors should give you some idea of what is going on.

This change will add your text into a new DIV within the site. I imagine you want it to do much more, but hopefully this helps you understand what was going wrong.

<button onclick="createHTMLalert()">Press for Announcements</button>
<script>

    function createHTMLalert(){
        if(!document.getElementById('announcements_alert')){
            let announcements_alert = document.createElement('div');
            announcements_alert.id = 'announcements_alert';
            document.body.appendChild(announcements_alert);
            announcements_alert.innerText = "New:\n- New Code\n- Update Button\n- About the Creator Section\n- Contact the Creator\n\nComing Soon:\n- Quote Code YouTube Channel\n- More Codes\n- Accounts\n- Commenting\n- Pre-made Code\n- C++ and C for Game Making\n- Quote Code Twitter Page\n- Code Park";
        }
    }
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文