How do I...?

Interact with Embedded Web Objects

In AutoPlay Media Studio, it is possible to navigate around your project using an embedded html file.

For example, let's assume that you want to have the following HTML file in a web object (let's name the file index.html):

<html>
<body>
<a href="#Page2">Go to Page 2</a>
</body>
</html>

  1. Create a web object on the application page that loads index.html. Name it "Web1".

  2. Insert the following script in the page's On Preload event:

Web.LoadURL("Web1", "AutoPlay\\Docs\\index.html");

The above line resets the web object named Web1 to AutoPlay\Docs\index.html. This is necessary because the URL in a web object will persist across pages, and the On Navigate event is called when the web object appears on the page after a page load; if we don't reset the URL in this web object whenever the page loads, it will still have the #Page2 URL in it, and our script in the On Navigate event (see below) will make the application jump right back to page 2.

  1. Insert the following script in the web object's On Navigate event:

-- search from right to left for a number sign (#)
nPos = String.ReverseFind(e_URL, "#", true);

-- did we find a # ?
if nPos then
    -- get everything to the right of the #
    strPage = String.Mid(e_URL, nPos + 1, -1);

    --[[ jump to the page name that we extracted from
         the URL. If there is no page by that name,
         the Page.Jump won't do anything. ]]
    Page.Jump(strPage);
end

Clicking on a link in this web object will trigger the On Navigate event and put the href string (the link target) into the event variable named e_URL. The String.ReverseFind action looks for the # symbol and, if found, a String.Mid action grabs everything to the right of the # symbol in the string. The resulting string is stored in a variable and then used as the target of a Page.Jump action.

Note: When the user clicks on the link 'Go to Page 2' in our example HTML file, the application will jump to "Page2".