我的应用正在查看文件夹,然后在下拉菜单中显示其中的所有文件夹和html文件,并在iframe中显示任何html文件。我有一个名为highlighted.html的文件,我不想在下拉菜单中显示,但如果它位于当前目录中,我想在iframe中自动显示它。
这是我的代码,用于显示文件夹中的内容: 第一个函数创建一个下拉框加载动态文件夹或文件(使用html扩展名)。 第二个功能:如果点击一个现有的子文件夹,然后打开该文件夹并查看html文件( s)在iframe中打开它
我在 tdhtestserver.herobo/ 上提供了一个工作演示。
已解决
解决方案你没有理解我的问题,或者他们不知道如何去做。所以我发现这很简单,我所做的只有一行代码。
high(currentSelectorPath +'/ '+ selectedOption.getAttribute(' 数据子文件夹 ')+'/ highlighted.html');这条线改变了一切,其中 high 是一个新的iframe
函数onFsSelectChange(el){ var currentSelectorPath = el.getAttribute('数据路径'), selectedOption = el.options [el.selectedIndex]; if(selectedOption.classList.contains('subfolder-option')){ loadFolderStructure(currentSelectorPath +'/'+ selectedOption.getAttribute('data-subfolder'),$(el )) high(currentSelectorPath +'/'+selectedOption.getAttribute('data-subfolder')+'/highlighted.html'); if(selectedOption.classList.contains('html-page-option')){ playSwf(currentSelectorPath +'/'+ selectedOption.getAttribute('data-html-page-名称') ); } }
My app is looking into a folder and then show all folders and html file inside it in a dropdown menu, and display any html files inside an iframe. I have a file called "highlighted.html" which I don't want to show in the dropdown menu, but if it is in the current directory I do want to show it automatically in an iframe.
This is my code to show what is in folder:
First function create a dropdown box loading dynamically folders or files (with html extension).
In second function: if click on an existing subfolder, then open that folder and look inside for html file(s) to open it in a iframe
function rendSelects($currentSelectItem, strPath) { var currentSelectLevel = (null === $currentSelectItem ? -1 : parseInt($currentSelectItem.attr('data-selector-level'))), nextOneSelectorHtml = '<select ' + 'class="dropdown selectpicker" ' + 'name="dd" ' + 'data-selector-level="' + (currentSelectLevel + 1) + '" ' + 'data-path="' + strPath + '" ' + 'onchange="onFsSelectChange(this)"' + '><option text selected> -- select an option -- </option>'; $('div.selectors-container select.dropdown').each(function (i, el) { if (parseInt(el.getAttribute('data-selector-level')) > currentSelectLevel) { el.parentNode.removeChild(el); $(el).selectpicker('destroy'); } }); if (fsStructure[strPath].subfolders.length > 0) { for (var i = 0; i < fsStructure[strPath].subfolders.length; i++) { nextOneSelectorHtml += '<option ' + 'class="subfolder-option" ' + 'data-subfolder="' + fsStructure[strPath].subfolders[i] + '" >' + fsStructure[strPath].subfolders[i] + '</option>'; } } if (fsStructure[strPath].subshtmls.length > 0) { for (var i = 0; i < fsStructure[strPath].subshtmls.length; i++) { nextOneSelectorHtml += '<option ' + 'class="html-page-option" ' + 'data-html-page-name="' + fsStructure[strPath].subshtmls[i] + '">' + fsStructure[strPath].subshtmls[i] + '</option>'; } } nextOneSelectorHtml += '</select>'; $('div.selectors-container').append(nextOneSelectorHtml); $('div.selectors-container').trigger('dropdownadded.mh'); } function onFsSelectChange(el) { var currentSelectorPath = el.getAttribute('data-path'), selectedOption = el.options[el.selectedIndex]; if (selectedOption.classList.contains('subfolder-option')) { loadFolderStructure(currentSelectorPath + '/' + selectedOption.getAttribute('data-subfolder'), $(el)) } if (selectedOption.classList.contains('html-page-option')) { playSwf(currentSelectorPath + '/' + selectedOption.getAttribute('data-html-page-name')); } }
I have provided a working demo at tdhtestserver.herobo/.
SOLVED
解决方案I answer on my question because some of you haven't understood my issue or they don't know how to do it. So I found that was so easy and all i've done was only one line of code.
high( currentSelectorPath + '/'+selectedOption.getAttribute('data-subfolder')+'/highlighted.html');This line was changed everything, where high is a new iframe
function onFsSelectChange( el ) { var currentSelectorPath = el.getAttribute('data-path'), selectedOption = el.options[el.selectedIndex]; if ( selectedOption.classList.contains('subfolder-option') ) { loadFolderStructure( currentSelectorPath + '/' + selectedOption.getAttribute('data-subfolder'), $(el) ) high( currentSelectorPath + '/'+selectedOption.getAttribute('data-subfolder')+'/highlighted.html'); } if ( selectedOption.classList.contains('html-page-option') ) { playSwf( currentSelectorPath + '/' + selectedOption.getAttribute('data-html-page-name') ); } }
更多推荐
如何用JavaScript找到一个文件?
发布评论