【发布时间】:2018-11-25 22:44:47
【问题描述】:
我正在尝试使用在 Github 页面上切换 iframe 源链接的功能。来自here.
iframe 源代码是 p5.js 草图,也托管在 Github 页面上。整个页面(121templatetwo)在本地工作,但是当推送到 Github Pages 时,iframe 是空的。
121templatetwo repo 链接:https://github.com/lilykdonaldson/121templatetwo
iframe 切换器的代码(也在 repo 中):
var switcher$ = $('.switcher'), // select element
switchTarget$ = $('.switch-target'); // iframe
switcher$.on('change', switchIframeSrc); // event binding
// our functiono to switch the iframe src
function switchIframeSrc() {
// set the 'src' attribute of the iframe
// to the value of the selected option
switchTarget$.attr('src', switcher$.val());
}
// call the method on load
switchIframeSrc();
以及 iframe 为空的 link to the Github Page。
【问题讨论】:
标签: javascript html iframe github-pages p5.js