Question

I have written an HTML Application (hta file) and am wondering if there is a way to embed an icon file into the hta file itself.

I have seen html emails that include embedded graphic files, is there any way to do this with html applications and icons?

HTA files have an HTA:APPLICATION tag that allows you to specify an icon, but I want to have only a single file for download. I don't want to have an external icon file. Is this possible?

More info on hta files here: HTA files.

Was it helpful?

Solution

I've found an hack to set the icon.

Prepare an icon file icon.ico and an hta file source.hta with the following contents:

<HTML>
<HEAD>
   <SCRIPT>
      path = document.URL;
      document.write(
       '<HTA:APPLICATION ID="oHTA" APPLICATIONNAME="myApp" ICON="'+path+'">');
   </SCRIPT>
</HEAD>
<BODY SCROLL="no">
  Hello, World!
</BODY>
</HTML>

Open a command prompt and type:

copy /b icon.ico+source.hta iconapp.hta

That will concatenate the icon and hta into a single file.

In my test case Internet explorer skipped over the icon data and display the HTML correctly.

The path of the icon is then set to that of the .hta file itself using javascript and the icon is loaded.

I have tested this on Windows XP SP3, Internet explorer 8.

OTHER TIPS

Consider using one of the applications in System32 for your icon.

This won't change the icon for an HTA file that's on the desktop, but once it's running it will add some personality to the task bar and such.

I often use the following to add a bit of charm to my HTAs.

<hta:application icon="magnify.exe" />

I don't believe it's possible to use icons from a library, but just open System32 in Explorer and change it to icon view and see if there are any icons that catch your fancy at all.

I remember seeing this a looong time ago:

<img src="data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7"width="16" height="14" alt="embedded folder icon">

I've never tried it myself though.

I know it's not exactly what the OP requested, but, instead of embedding an icon in the .hta, have you consider a URL to an icon file? Many websites have a website icon favicon.ico which works in HTA applications:

<HTML>
<HEAD>
   <HTA:APPLICATION
       ID="oHTA"
       APPLICATIONNAME="myApp"
       ICON="http://stackoverflow.com/favicon.ico">
</HEAD>
<BODY SCROLL="no">
  Hello, World!
</BODY>
</HTML>

This gives you limitless choices in icons without the need to deploy one with your HTA application.

Quite possibly ... there is a way to embed images directly into an html file that may work for this http://www.sveinbjorn.org/news/2005-11-28-02-39-23

Another possible solution, but not completely compliant with the exact phrasing of the question, would be to convert the HTA into an .EXE file using the "HTAedit" application (http://www.htaedit.com/).

They offer a trial version that is compltely functional (just some startup nag screen and no history/recent files) without blocking creation of .EXE from the HTA source, with no time limit.

You can then declare your icon with the ICON="myicon.ico" statement in the HTA header block, then when it "compiles" (according to my opinion it's more likely rather a packager than a real compiler but that's not the point here) it ask you for additional resource files. If your icon file is not already listed there, then just add it into the list, "et voilà !". You get a nice executable with it's version number and embedded icon.

Actually that's what I did with the Microsoft Scripting Guys tools (HTA_HELPOMATIC.HTA and SCRIPTOMATIC.HTA): I just changed them in EXE adding an icon from some %windir%\system32 exe/dll I found matching more or less the meaning of the tools, and it worked perfectly.

On the run it might be more portable than just embedding the icon into the HTA (HTAedit tool seems to be able to produce W7/64 executables but I did not test it that way, I'm still under XP32-SP2...) and it keeps your source hta file readable and editable by a text editor.

IE doesn't support data URIs, so you're going to have to use an external file if you use the img tag.

The only thing I can think of is to use VML, which has been around since IE5. It's an SVG-like vector image format that can be used inline. For example, draw something using this VML editor and click "Get code". You can plop that in your HTA. I'm not aware of anything that will convert your image to VML directly, but I believe there is a way to export to VML from some Office products.

It's a pretty far-fetched answer, but you could embed the icon as base64-encoded XML in the HTA, then use JavaScript onload and save the icon file to a temporary location. The ActiveX Object MSXML.DomDocument can encode and decode base64 nodes.

As soon as you need an <iframe> or other HTML dialog you're going to want additional files anyway. You'll generaly find that .CSS and .VBS files separate from the .HTA make programming and support a lot easier for any non-trivial HTA too.

One alternative for doing this as "a single EXE" is to wrap everything up as a self-extracting archive or via IExpress. When the user "runs your program" it extracts everything from your archive into a temp directory and runs the item of your choice.

There are 3rd party alternatives like HTMLApp too.

Another solution, but not completely compliant with the exact phrasing of the question, is to create a simple shortcut. For 64-bit systems you should enter:

target: C:\Windows\SysWOW64\mshta.exe C:\path+filename.hta

start in: C:\Windows\SysWOW64

You can manually change the icon of the shortcut. The user can drag the shortcut to the taskbar.

The extention of the hta file is of no importance to mshta.exe. So if you give it a custom extension, then the hta files will show with the corresponding custom icon.

You could embed a base64 encoded image into the HTA and create the file locally on the first execution.

Below is a HTA that creates a "favicon.ico" (https://stackoverflow.com/favicon.ico) file from a base64 string. It can encode an image file also (with code adapted from Base64 Encode String in VBScript and VBScript to open a dialog to select a filepath).

<!DOCTYPE html>
<html>
<head>
 <HTA:APPLICATION
    ID="oHta"
    APPLICATIONNAME="Icon test..."
    ICON="favicon.ico"
 />
<LINK id=shortcutlink REL="SHORTCUT ICON" HREF="favicon.ico">
<META http-equiv="x-ua-compatible" content="text/html; charset=utf-8">
<TITLE>Icon test</TITLE>
</head>

<script language=vbscript>

Function fBase64Encode(sourceStr)

    Dim rarr()

    carr = Array(   "A", "B", "C", "D", "E", "F", "G", "H", _
                    "I", "J", "K", "L", "M", "N", "O" ,"P", _
                    "Q", "R", "S", "T", "U", "V", "W", "X", _
                    "Y", "Z", "a", "b", "c", "d", "e", "f", _
                    "g", "h", "i", "j", "k", "l", "m", "n", _
                    "o", "p", "q", "r", "s", "t", "u", "v", _
                    "w", "x", "y", "z", "0", "1", "2", "3", _
                    "4", "5", "6", "7", "8", "9", "+", "/")     

    n = Len(sourceStr)-1

    ReDim rarr(n\3)

    For i=0 To n Step 3
        a = Asc(Mid(sourceStr,i+1,1))
        If i < n Then
            b = Asc(Mid(sourceStr,i+2,1))
        Else
            b = 0
        End If
        If i < n-1 Then
            c = Asc(Mid(sourceStr,i+3,1))
        Else
            c = 0
        End If
        rarr(i\3) = carr(a\4) & carr((a And 3) * 16 + b\16) & carr((b And 15) * 4 + c\64) & carr(c And 63)
    Next

    i = UBound(rarr)
    If n Mod 3 = 0 Then
        rarr(i) = Left(rarr(i),2) & "=="
    ElseIf n Mod 3 = 1 Then
        rarr(i) = Left(rarr(i),3) & "="
    End If

    fBase64Encode = Join(rarr,"")

End Function
'-------------------------------------------------------------------------------

function fBase64Decode(str)

    fBase64Decode = ""

    table = fGenerateBase64Table

    bits = 0

    for x = 1 to len(str) step 1
        c = table(1+asc(mid(str,x,1)))
        if (c <> -1) then
            if (bits = 0) then
                outword = c*4
                bits = 6
            elseif (bits = 2) then
                outword = c+outword
                strBase64 = strBase64 & chr(clng("&H" & hex(outword mod 256)))
                bits = 0
            elseif (bits = 4) then
                outword = outword + int(c/4)
                strBase64 = strBase64 & chr(clng("&H" & hex(outword mod 256)))
                outword = c*64
                bits = 2
            else
                outword = outword + int(c/16)
                strBase64 = strBase64 & chr(clng("&H" & hex(outword mod 256)))
                outword = c*16
                bits = 4
            end if
        end if
    next

    fBase64Decode = strBase64

end function
'---------------------------------------------------

function fGenerateBase64Table()

    r64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

    'set up decode table
    dim table(256)
    for x = 1 to 256 step 1
        table(x) = -1
    next
    for x = 1 to 64 step 1
        table(1+asc(mid(r64,x,1))) = x - 1
    next

    fGenerateBase64Table = table

end function
'---------------------------------------------------

function fSelectFile()

    fSelectFile = ""
    strMSHTA = "mshta.exe ""about:<input type=file id=FILE>" & _
               "<"&"script>FILE.click();new ActiveXObject('Scripting.FileSystemObject')" & _
               ".GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);<"&"/script>"""

    Set wshShell = CreateObject( "WScript.Shell" )
    Set objExec = wshShell.Exec( strMSHTA )
    fSelectFile = objExec.StdOut.ReadLine( )
    Set objExec = Nothing
    Set wshShell = Nothing

end function

'-------------------------------------------------------------------------

sub getBase64()

    'this can be BMP, PNG, ICO
    REM sImgFile = "favicon.ico"
    sImgFile = fSelectFile()

    if sImgFile = "" then exit sub

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFile(sImgFile)
    filesize = f.size
    set f = fso.opentextfile(sImgFile,1,0) 'open as ascii
    strBinFile = f.read(filesize)
    f.close
    set fso = nothing

    strPNGFile = fBase64Encode(strBinFile)
    s = s & "Base64 encoding of "&sImgFile&"<br><br>" & strPNGFile & "<br><br>"
    s = s & "<img src=""data:image/bmp;base64," & strPNGFile & """><br><br>" & vbcrlf

    imgbase64.innerhtml = s

end sub
'-------------------------------------------------------------------------

sub setup()

    'https://stackoverflow.com/favicon.ico in base64 
    base64Icon="AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv8AAAAAAAAAAAAAAAAAAAAAAAAAAKmjnv8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACpo57/AAAAAAAAAAAAAAAAAAAAAAAAAACpo57/AAAAAAlw8v8JcPL/CXDy/wlw8v8JcPL/CXDy/wlw8v8AAAAAqaOe/wAAAAAAAAAAAAAAAAAAAAAAAAAAqaOe/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlw8hMJcPI2AAAAAKmjnv8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACXDyLwlw8l0JcPKJCXDytglw8uIJcPLvCXDyvQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlw8sIJcPKlCXDydwlw8kkJcPIdCXDyEwlw8nEJcPIvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJcPI9CXDypQlw8u8JcPKgCXDyLwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACXDyDwlw8nEJcPLWCXDy0wlw8msJcPIPCXDyPQlw8uIJcPInAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlw8iMJcPKgCXDyOgAAAAAAAAAACXDydwlw8ugJcPJGCXDyUQlw8oIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJcPITCXDytglw8sIJcPIdCXDyGAlw8ugJcPI2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJcPI6CXDy4glw8okJcPIDAAAAAAlw8rYJcPJ+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACXDyZAlw8kkAAAAAAAAAAAlw8msJcPLICXDyAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlw8icJcPLoCXDyIwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJcPLCCXDyZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACXDyHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//AADABwAA3/cAANAXAADflwAA8B8AAPAPAAD+DwAA8AcAAPGDAAD+AwAA/CcAAPzHAAD/jwAA/58AAP+/AAAoAAAAIAAAAEAAAAABACAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAA////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAKmjngCpo54AqaOeAP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wCpo54AqaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po54A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AKmjngCpo57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjnv+po57/qaOe/6mjngD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8AqaOeAKmjnv+po57/JID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0AKmjnv+po57/JID0ACSA9AAkgPQAJID0AP///wD///8A////AP///wD///8A////AP///wCpo54AqaOe/6mjnv8kgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAqaOe/6mjnv8kgPQAJID0ACSA9AAkgPQA////AP///wD///8A////AP///wD///8A////AKmjngCpo57/qaOe/ySA9AAkgPQAJID0/ySA9P8kgPT/JID0/ySA9P8kgPT/JID0/ySA9P8kgPT/JID0/ySA9P8kgPT/JID0ACSA9ACpo57/qaOe/ySA9AAkgPQAJID0ACSA9AD///8A////AP///wD///8A////AP///wD///8AqaOeAKmjnv+po57/JID0ACSA9AAkgPT/JID0/ySA9P8kgPT/JID0/ySA9P8kgPT/JID0/ySA9P8kgPT/JID0/ySA9P8kgPQAJID0AKmjnv+po57/JID0ACSA9AAkgPQAJID0AP///wD///8A////AP///wD///8A////AP///wCpo54AqaOe/6mjnv8kgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAqaOe/6mjnv8kgPQAJID0ACSA9AAkgPQA////AP///wD///8A////AP///wD///8A////AKmjngCpo57/qaOe/ySA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9B4kgPRRJID0gSSA9LQkgPTjJID0EiSA9ACpo57/qaOe/ySA9AAkgPQAJID0ACSA9AD///8A////AP///wD///8A////AP///wD///8AqaOeAKmjngCpo54AJID0ACSA9AAkgPQAJID0AiSA9CYkgPRXJID0iSSA9LokgPTtJID0/ySA9P8kgPT/JID0/ySA9P8kgPRKJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAkgPQAJID0ACSA9LgkgPTxJID0/ySA9P8kgPT/JID0/ySA9P8kgPT/JID0+SSA9M0kgPSaJID0aiSA9CQkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQA////AP///wD///8A////AP///wD///8A////AP///wD///8A////ACSA9AAkgPQAJID0vSSA9P8kgPT/JID09CSA9MUkgPSUJID0YiSA9DEkgPQFJID0ACSA9DQkgPSjJID05iSA9A0kgPQAJID0ACSA9AAkgPQAJID0ACSA9AD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8AJID0ACSA9AAkgPRKJID0WySA9CkkgPQDJID0ACSA9AAkgPQAJID0BSSA9FgkgPTHJID0/ySA9P8kgPT/JID0eCSA9AAkgPQAJID0ACSA9AAkgPQAJID0AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0FSSA9HwkgPTkJID0/ySA9P8kgPT/JID02SSA9GwkgPQ9JID0LCSA9AAkgPQAJID0ACSA9AAkgPQA////AP///wD///8A////AP///wD///8A////AP///wD///8A////ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0MiSA9J8kgPT4JID0/ySA9P8kgPT+JID0tySA9EkkgPQCJID0YiSA9PckgPTjJID0HCSA9AAkgPQAJID0ACSA9AD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8AJID0ACSA9AAkgPQAJID0KiSA9MIkgPT/JID0/ySA9P8kgPTyJID0lCSA9CYkgPQAJID0CCSA9J8kgPT/JID0/ySA9OkkgPRGJID0IySA9AAkgPQAJID0AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAkgPQAJID0ACSA9AAkgPQPJID07iSA9P8kgPTcJID0cCSA9A8kgPQAJID0ACSA9CQkgPTPJID0/ySA9P8kgPTDJID0HCSA9K4kgPTzJID0ZiSA9AAkgPQA////AP///wD///8A////AP///wD///8A////AP///wD///8A////ACSA9AAkgPQAJID0ACSA9AAkgPRaJID0TCSA9AIkgPQAJID0ACSA9AAkgPRQJID07ySA9P8kgPT+JID0jiSA9AUkgPR+JID0/ySA9P8kgPSOJID0ACSA9AD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8AJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQEJID0iCSA9P4kgPT/JID08SSA9FQkgPQAJID0TSSA9P4kgPT/JID0uySA9AMkgPQAJID0AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0GCSA9MAkgPT/JID0/ySA9NMkgPQmJID0ACSA9CgkgPTwJID0/ySA9N4kgPQUJID0ACSA9AAkgPQA////AP///wD///8A////AP///wD///8A////AP///wD///8A////ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9B8kgPTnJID0/ySA9P8kgPSiJID0CiSA9AAkgPQPJID02CSA9P8kgPT1JID0LiSA9AAkgPQAJID0ACSA9AD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8AJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9JYkgPT4JID0ZySA9AAkgPQAJID0AiSA9LQkgPT/JID0/iSA9FYkgPQAJID0ACSA9AAkgPQAJID0AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0AySA9CokgPQAJID0ACSA9AAkgPSCJID0/ySA9P8kgPSIJID0ACSA9AAkgPQAJID0ACSA9AAkgPQA////AP///wD///8A////AP///wD///8A////AP///wD///8A////ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0UySA9P4kgPT/JID0tySA9AMkgPQAJID0ACSA9AAkgPQAJID0ACSA9AD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8AJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9A8kgPTvJID0/ySA9NskgPQQJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9DQkgPTIJID0LCSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQA////AP///wD///8A////AP///wD///8A////AP///wD///8A////ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8AJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0ACSA9AAkgPQAJID0AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP////////////////wAAD/8AAA//P//P/z//z/8wAM//MADP/z//z/8/4E//+AB///AAf//wBD//8OA///+AH//+AA//+AQH//gYA//8cAP//8CD//+BB///Ag///4wf//+cP///+D////B////4///////////////////////"    

    Set fso = CreateObject("Scripting.FileSystemObject")
    if not fso.fileexists("favicon.ico") then
        strBin = fBase64Decode(base64Icon)
        set outfile = fso.createtextfile("favicon.ico")
        outfile.write strBin
        outfile.close

        document.title = "Need to refresh to see the new icon"

    end if    
    set fso = nothing

end sub  

</script>

<style type="text/css">

    body  {font-family:"CONSOLAS";font-size:"10pt";}
    input  {font-family:"CONSOLAS";font-size:"8pt";}

</style>

<body onLoad=setup()>

<input type=button value="Encode an image file..." 
data-tooltip title="Choose a PNG, BMP, ICO file to encode in base64" 
onclick=getBase64>

<br><br>

<div id=imgbase64 style="word-wrap: break-word;"></div>

</body>
</html>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top