【发布时间】:2021-11-15 23:34:30
【问题描述】:
我尝试做一个通知系统,每次有人发布新帖子时都会播放声音。 我在 boostrap 4 工作 我已经通过在函数页面中插入 javascript 来改变方法,但是当我调用 javascript 函数时,我会以各种方式出现与之前相同的错误 我只发布所有代码的一部分,因为是维度 我调用的脚本是 play_sound 我像这样呼唤回声
echo '<script type="text/javascript">play_sound();</script>';
然后我得到了同样的错误
This is my error
警告:无法修改标头信息 - 标头已由第 208 行的 /home/nicetaxi/public_html/helpers/Functions.php 中的 /home/nicetaxi/public_html/helpers/Functions.php:1 发送的标头
这是我的错误所在
function redirect_to_page($path = null)
{
header("location:" . SITE_ADDR . $path);
}
How can i solve this error
This is the functions page
<script type="text/javascript">
function play_sound() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'https://www.nicetaxi.eu/download/notifications.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
audioElement.setAttribute('muted', 'muted');
audioElement.load();
audioElement.play();
}
</script>
<?php
【问题讨论】:
标签: javascript php bootstrap-4