Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/404.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用单个html文件显示本地文件夹中的所有图像_Javascript_Html_Vbscript - Fatal编程技术网

Javascript 使用单个html文件显示本地文件夹中的所有图像

Javascript 使用单个html文件显示本地文件夹中的所有图像,javascript,html,vbscript,Javascript,Html,Vbscript,首先,所有这些活动都被认为是本地的。简单地说,没有web服务器 我有两个步骤 使用VBS创建html文件,并使用指向我在msgbox中键入的特定文件夹中的图像的链接填充该文件 在我选择的浏览器中打开html文件 我花了一个徒劳的晚上试图将其合并到一个单一步骤中——html页面有一个输入框,按下按钮-->会显示图像 现在需要澄清的是,VBS脚本输出只是 img src=“c:\temp\01.png”带有开始和结束标记,其中temp文件夹中有一个名为01.png的文件,然后02.png将位于该文件

首先,所有这些活动都被认为是本地的。简单地说,没有web服务器

我有两个步骤

  • 使用VBS创建html文件,并使用指向我在msgbox中键入的特定文件夹中的图像的链接填充该文件

  • 在我选择的浏览器中打开html文件

  • 我花了一个徒劳的晚上试图将其合并到一个单一步骤中——html页面有一个输入框,按下按钮-->会显示图像

    现在需要澄清的是,VBS脚本输出只是

    img src=“c:\temp\01.png”

    带有开始和结束标记,其中temp文件夹中有一个名为01.png的文件,然后02.png将位于该文件下方,以此类推

    我今晚的尝试是想找到一种方法,用document.write或类似的东西在页面上简单地显示一个文件列表,但我没有做到这一点。任何访问文件系统的尝试似乎都会导致脚本失败

    谢谢你的帮助


    我现在有一个vbscript作为我的第一步。我想知道如何将函数/html输出嵌入到单个html文件中

    我设想html页面将有一个输入字段,一个“go”按钮,然后结果将是页面上出现的文件夹中的图像。所有这些都使用客户端脚本

    我的vbscript与下面的脚本非常相似,但因为我知道我只会得到png,所以我只想得到它(这也是我应该得到的)

    对不起,如果我一直把东西放错地方

    下面是当前HTML示例输出

    <html><head></head><body>
    <img src = "c:\temp\credit.png"<hr>.<hr>
    <img src = "c:\temp\NTK_01.png"<hr>.<hr>
    </body></html>
    
    
    .
    .
    -

    dim objFSO
    dim objFolder
    暗色文件
    dim文件列表
    dim objStartFolder
    暗淡路径图像
    迪米安
    iend=“”

    “&vbcrlf'vbcrlf if仅用于html的可读性 const isrc=“&vbcrlf”创建html代码并将其存储在此变量中。 对于colFiles中的每个objFile “应该只有图像,但我在测试时创建了它,并将其保留了下来。 如果right(objFile.Name,3)=“png”,则 pathToImage=objFolder.path&“\”&objFile.Name filelist=filelist&isrc&pathToImage&iend '输出行应为: “

    如果结束 下一个 filelist=filelist&''关闭html数据 wscript.echo文件列表'显示html文件的外观-健全性检查。 '打开文件,覆盖现有内容并关闭文件 设置htmlout=objFSO.OpenTextFile(FileToWrite,用于写入,TRUE) htmlout.write文件列表 htmlout.close
    您可以从以下示例开始:IMG2HTML.vbs

    'This VBScript Scan and Search for images with extension like jpg,gif,png,bmp 
    'in the folder and subfolders and list them in a html output file.
    '© Hackoo © 2011
    start_folder = ".\" ' The Current Directory for scaning images
    htmfile = "ListImage.htm"
    ext = Array("jpg","gif","png","bmp") 
    count=0
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set folder = fso.GetFolder(start_folder)
    Set ws = CreateObject("WScript.Shell")
    Set outfile = fso.CreateTextFile(htmfile)
    outfile.WriteLine "<html><body>"
    ListDirectory folder, ext    'Call The Recursive function
    outfile.WriteLine "<br><center><font color=red>Le Nombre total des images est de "& count & "</font>"
    outfile.WriteLine "</body></html>"
    outfile.Close
    Question = MsgBox("The Total Count of images is " & count & vbCrLf &" Do you want to List them now ?",vbYesNo+32,"Total Count of images")
    If Question = vbYes Then
        Explorer htmfile
    else
        wscript.Quit
    End If
    '******************************************
    Sub ListDirectory(folder, ext)
        For Each file In folder.Files
            cheminFic = folder & "\" & file.name
            For i = lbound(ext) to ubound(ext)
                If UCase(ext(i)) = UCase(fso.GetExtensionName(file.Name)) Then
                    strFilePath = file.ParentFolder
                    outfile.WriteLine "<center><a target=_Blank href="& qq("file:///" & cheminFic) &""">"&_
                    "<img src="& qq("file:///" & cheminFic) &" width=70 height=70><BR><B><font color=red>"&_
                    "<a href="& qq("file:///" & strFilePath) &">" & file.Name & "</a></font><B><br><hr>"
                    count=count+1
                End If
            Next        
        Next
        For Each fldr In folder.subfolders
            ListDirectory fldr, ext
        Next
    End Sub
    '******************************************
    Function Explorer(File)
        Set ws=CreateObject("wscript.shell")
        ws.run "Explorer "& File & "\"
    end Function
    '******************************************
    Function qq(strIn) 
        qq = Chr(34) & strIn & Chr(34)
    End Function
    '******************************************
    
    '此VBScript扫描并搜索扩展名为jpg、gif、png、bmp的图像
    '并将其列在html输出文件中。
    ©Hackoo©2011
    start\u folder=“.\””用于扫描图像的当前目录
    htmfile=“ListImage.htm”
    ext=数组(“jpg”、“gif”、“png”、“bmp”)
    计数=0
    设置fso=CreateObject(“Scripting.FileSystemObject”)
    Set folder=fso.GetFolder(启动文件夹)
    设置ws=CreateObject(“WScript.Shell”)
    Set outfile=fso.CreateTextFile(htmfile)
    outfile.WriteLine“”
    ListDirectory文件夹,ext'调用递归函数
    outfile.WriteLine“
    图像的总名称和计数” outfile.WriteLine“” 出口,关闭 Question=MsgBox(“图像总数为”&Count&vbCrLf&“是否立即列出它们?”,vbYesNo+32,“图像总数”) 如果问题=是,那么 浏览器HTML文件 其他的 wscript.Quit 如果结束 '****************************************** 子列表目录(文件夹,外部) 对于文件夹.Files中的每个文件 cheminFic=文件夹&“\”&file.name 对于i=lbound(ext)到ubound(ext) 如果UCase(ext(i))=UCase(fso.GetExtensionName(file.Name)),那么 strFilePath=file.ParentFolder outfile.WriteLine“

    ” 计数=计数+1 如果结束 下一个 下一个 对于folder.subfolders中的每个fldr 列表目录fldr,ext 下一个 端接头 '****************************************** 函数资源管理器(文件) 设置ws=CreateObject(“wscript.shell”) ws.run“Explorer”&文件&“\” 端函数 '****************************************** 功能qq(strIn) qq=Chr(34)和strIn&Chr(34) 端函数 '******************************************
    您的HTML文件中是否有可以共享的代码?您是否像
    那样包装src?我不知道vbs,但您似乎可以在这里找到答案。也许,你也应该使用文件uri方案来链接本地文件,因为所有东西都是本地的,没有web服务器,我希望我可以绕过安全问题。Ken Kwok链接的文件系统似乎不受支持。当然我可能弄错了。我现在有一个vbscript作为我的第一步。我想知道如何将函数/html输出嵌入到单个html文件中。我设想html页面将有一个输入字段,一个“go”按钮,然后结果将是图像列表。我的vbscript和你的非常相似,但因为我知道我只会得到png,这就是我所要寻找的(以及所有应该在那里的东西)。你说的HTML是HTA吗??
    'This VBScript Scan and Search for images with extension like jpg,gif,png,bmp 
    'in the folder and subfolders and list them in a html output file.
    '© Hackoo © 2011
    start_folder = ".\" ' The Current Directory for scaning images
    htmfile = "ListImage.htm"
    ext = Array("jpg","gif","png","bmp") 
    count=0
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set folder = fso.GetFolder(start_folder)
    Set ws = CreateObject("WScript.Shell")
    Set outfile = fso.CreateTextFile(htmfile)
    outfile.WriteLine "<html><body>"
    ListDirectory folder, ext    'Call The Recursive function
    outfile.WriteLine "<br><center><font color=red>Le Nombre total des images est de "& count & "</font>"
    outfile.WriteLine "</body></html>"
    outfile.Close
    Question = MsgBox("The Total Count of images is " & count & vbCrLf &" Do you want to List them now ?",vbYesNo+32,"Total Count of images")
    If Question = vbYes Then
        Explorer htmfile
    else
        wscript.Quit
    End If
    '******************************************
    Sub ListDirectory(folder, ext)
        For Each file In folder.Files
            cheminFic = folder & "\" & file.name
            For i = lbound(ext) to ubound(ext)
                If UCase(ext(i)) = UCase(fso.GetExtensionName(file.Name)) Then
                    strFilePath = file.ParentFolder
                    outfile.WriteLine "<center><a target=_Blank href="& qq("file:///" & cheminFic) &""">"&_
                    "<img src="& qq("file:///" & cheminFic) &" width=70 height=70><BR><B><font color=red>"&_
                    "<a href="& qq("file:///" & strFilePath) &">" & file.Name & "</a></font><B><br><hr>"
                    count=count+1
                End If
            Next        
        Next
        For Each fldr In folder.subfolders
            ListDirectory fldr, ext
        Next
    End Sub
    '******************************************
    Function Explorer(File)
        Set ws=CreateObject("wscript.shell")
        ws.run "Explorer "& File & "\"
    end Function
    '******************************************
    Function qq(strIn) 
        qq = Chr(34) & strIn & Chr(34)
    End Function
    '******************************************