Navigation: For Developers > Extend Functionality with HEScript > Sample Scripts > |
|
This tutorial, which explains how to access subfolders within a compiled website on a CD using HTML Executable, will guide you through the steps in a straightforward and concise fashion. Let's begin!
You want to create a compiled website on a CD, with the .exe file in the root of the CD. This website needs to open subfolders of the CD in Windows Explorer. This can be achieved by making some changes to your HTML code. The best approach is to use an HEScript script function. This function would be invoked from your HTML code and will open the subfolder you specify with a parameter.
Open your HTML Executable project and navigate to the Script Manager. Double-click the "UserMain" script to open the script editor. Add the following function code:
procedure OpenSubFolder(FolderName: String);
var
EbookPath, MyFolder: String;
begin
EbookPath := GetGlobalVar("HEPublicationPath", "");
MyFolder := EbookPath + FolderName + " ";
OpenFile(MyFolder, "", SW_SHOWNORMAL);
end;
Don't forget to save your script!
Edit the HTML page with the links that should open the subfolder. Replace the links with the following HTML code:
<a href="hescript://UserMain.OpenSubFolder|FOLDER NAME">Open Folder</a>
Replace `FOLDER NAME` with the name of the folder after the `|` character. Please note that folders shouldn't have spaces (or use the `%20` character like for URLs).
For instance, if you have this CD structure:
ROOT
Mycompiledwebsite.exe (the compiled .exe file)
-- Folder1 (a subfolder)
-- Folder2 (another subfolder)
If you want a link that opens "Folder1", use this HTML code:
<a href="hescript://UserMain.OpenSubFolder|Folder1">Open Folder 1</a>
Compile your project and that's it!