【发布时间】:2017-10-17 00:45:20
【问题描述】:
我在尝试将 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);
虽然它在测试时有效,但在方形空间中无效。我收到 404 not found 错误。
关于可能发生的事情或搞砸的任何想法?任何查看方向或建议将不胜感激。
【问题讨论】:
-
我猜它与
document.write()有关。请改用Element.innerHTML = html;。
标签: javascript squarespace video-embedding