我需要知道如何根据目录中有多少个html文件自动创建Iframes。假设我在main.html所在的子目录中有1.html和2.html。我想自动创建2个框架(在main.html中),一个显示1.html,另一个显示2.html。顺便说一句,如果你看不出来,2.html和1.html是本地文件
发布于 2016-03-03 14:33:40
向服务器发出ajax调用,以获取目录中的文件列表
httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function(){
//iterate the list and call addIframe( src ) for each of them
};
httpRequest.open('GET', "listFilesInDirectory");
httpRequest.send();这就是addIframe的样子
function addIframe( src )
{
var iframe = document.createElement('iframe');
iframe.src = src;
iframe.style.width = "640px";
iframe.style.height = "px";
document.body.appendChild(iframe);
}
addIframe( "subdir/1.html" );
addIframe( "subdir/2.html" );https://stackoverflow.com/questions/35764713
复制相似问题