Insert and design search field in layout


#1

Hello.
I have my custom search field in html book layout. Is it any opportunity to use my search field to search data in my html files?


#2

Yes, that’s possible thanks to the HEScript script engine of HTML Executable.
Is your custom field search managed with JavaScript?


#3

Can you explain? At now my search field is <input type="text" name="search" / > and submit button =)
I tried to realize search with JS (creating object with chapters of book and parse them), but it finished bad (can’t understand how to get all chapters links from certain page (Book contents page))


#4

Here is the idea you should implement:

From http://www.htmlexe.com/help/scriptreference

StartFullSearch
Launches a full text search in the entire publication. The Search engine must have been enabled!
The search results are displayed in the navigation panel.
procedure StartFullSearch(const Query: String; ScriptFormatName: String);
Query: what you are looking for. You may use the logical operators AND, OR, NOT.

ScriptFormatName: script of the search engine. Must be “search.hex”.

  1. So go to the Scripts tab in HTMLEXE:

In the Publication Behavior, you have an “User Scripts” tab with a default UserMain script. This script contains pre-defined events. Just edit UserMain and add this code:

procedure DoSearch(text: string);
begin
StartFullSearch(text, “search.hex”);
end;

  1. In your HTML code, associate a JavaScript onclick function to your search button
    The function should execute the DoSearch event defined previously. To do so, use this JS code:

    function searchbuttonclick()
    {
    textsearch = // read value from input text
    window.external.runHEScriptCom(“UserMain.DoSearch|” + textsearch);
    return 0;
    }