我想使用我在网页上引用该脚本的Google文档,调用Google API来访问YouTube列表:
<script src="https://apis.google.com/js/client.js?onload=onClientLoad"></script>
<script>
function onClientLoad() {
alert(1);
}
</script>
永远不会调用onload函数,我不确定我缺少什么吗?!
我正在尝试将解决方案与API KEY一起使用,但是根据文档,我需要在onClientLoad调用后提供API Key。
最佳答案
找到了答案,这是一个诚实的错误!
需要更改脚本标签的顺序:
<script>
function onClientLoad() {
alert(1);
}
</script>
<script src="https://apis.google.com/js/client.js?onload=onClientLoad"></script>
关于javascript - JavaScript中的Google YouTube API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25395182/