我在尝试将javascript嵌入到我的squarespace封面页时遇到了一个问题。该脚本是加载一个随机视频从vimeo时,他们按下播放按钮。我当前的网站有相同的播放按钮,但它只播放最新的http://www.andrewlozano.com/
我尝试使用的代码是这样的
var videos = [
'238243092',
'235209416',
'187960907',
'187960695',
'187960573',
'187960448',
'187960364',
'187960175',
'187960026',
'187959808',
'187959623',
'187959099',
];
var index=Math.floor(Math.random() * videos.length);
var html='<div class="embed"><iframe src="https://player.vimeo.com/video/' + videos[index] + '" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>';
document.write(html);
但是,虽然它在测试时可以工作,但在squarespace中却不能工作。我得到一个404未找到的错误。
有没有什么想法是可能发生的,或者是什么搞砸了?任何方向,以寻找或建议,将不胜感激。
发布于 2018-05-18 04:33:56
尝试以下代码:
var videos = [
'238243092',
'235209416',
'187960907',
'187960695',
'187960573',
'187960448',
'187960364',
'187960175',
'187960026',
'187959808',
'187959623',
'187959099',
];
var index=Math.floor(Math.random() * videos.length);
var html='<div class="embed"><iframe src="https://player.vimeo.com/video/' + videos[index] + '" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>';
var body = document.querySelector('body');
body.innerHTML = html;https://stackoverflow.com/questions/46780891
复制相似问题