The Web Browser object allows you to display HTML documents and other Internet content inside your publication. Use the Web Browser to incorporate live Internet content, such as advertisements or a related web site, into your publication. You could even link to a secure online order system to allow readers to order products directly from your publication. It's also possible to establish two-way communication between Web Browser content and your publication.


To create a Web Browser, use the mouse to draw a rectangle where you would like the object to appear. The Web Browser Box Properties screen will be displayed, allowing you to define the object’s appearance and behavior.



The Web Browser Properties screen is divided into two sections, indicated by the icon images on the left: General and Actions. To view the settings for a section, click the corresponding icon.


General

Enter the address of the web site or HTML document you want to display in the Internet Address or HTML File field. You can select a local HTML file (one located on your computer) by clicking the button to the right of this field; experienced authors can use the button to perform advanced file options or the button to replace the file name with a variable.


If you select a local file, it will remain external until the compile stage, when it will be bound inside the publication for distribution. During this process, the compiler will parse the document and include any required images. If the document includes links to other HTML files, those will be included and parsed as well.


There are three variables that can be assigned to the Web Browser to provide information about the currently displayed web site or HTML document. VisualNEO Win will assign variable names based on the Object Name, but you may change these names by modifying the appropriate fields. Unlike most other VisualNEO Win variables, these are read-only and cannot be modified to affect the state of the Web Browser. The variables are described below:


Variable to store current address (URL): This variable will be updated each time the contents of the Browser changes. Initially, this will be the same as the Internet Address specified above but will change if the reader is allowed to navigate to another web site. (To change the address at runtime, use the BrowserGoTo Action rather than modifying this variable directly.)


Variable to store current web page title: This variable will contain the title of the current HTML document displayed in the Browser. The title is specified within the HTML code by the document’s author. Commercial browser’s, such as Internet Explorer, Chrome and FireFox, usually display a document’s title at the top of the screen. You can do that too by creating a Simple Text object containing this variable‘s name.


Variable to store browser’s status text: This variable will be updated whenever the Browser has status information to present to the reader. Status information changes when downloading a new document or when the reader’s mouse pointer passes over a hyperlink. You can share this information with readers by creating a Simple Text object containing this variable’s name.


If desired, you can prevent readers from accessing the Browser’s Context menu, which normally appears if you right click the Browser window. A standard browser feature, the Context Menu provides readers with navigational commands. If you want to control which browser commands your readers can access, turn this option off.


You may enable the Silent mode option to prevent the Browser from generating any messages or dialog boxes on its own. For example, when Silent Mode is disabled, the BrowserPrint Action will display the Windows Print Screen before printing. When Silent Mode is on, the document will print immediately, without showing the Print Screen.


Select Hide scroll bars if you want the Browser window to be displayed without scroll bars. This can be handy if you're displaying some type of special content that fits exactly within the boundaries of the Browser. (Internet Explorer's natural inclination is to add a scroll bar whether one is needed or not.)


When the Trap popup windows option is enabled, VisualNEO Win will attempt to capture any requests to open new Browser windows and redirect the content to a window that contains a VisualNEO Win Web Browser object. When this option is disabled, any requests to display additional windows will be handled by Internet Explorer.


Enabling the Show tool bar option instructs VisualNEO Win to add a simple navigation bar to the top of the Browser. The navigation bar includes buttons for moving Backward and Forward as well as Stop and Refresh. The images used for the tool bar can be found in the "VisualNEO Win 5\Buttons\Resources" folder. If desired, you can change the appearance of the navigation buttons by editing these files using your favorite paint program. You can change the content of these files, but do not change their height or width.


Select the Show status bar option to add a simple status bar to the bottom of the Browser. The status bar will display the Browser's current status text. A small progress bar will also appear whenever the Browser is waiting for files to download.


When the Enhanced Security option is enabled, VisualNEO Win will not allow potentially dangerous Actions embedded within HTML hyperlinks to be executed. (See Embedding VisualNEO Win Actions Inside an HTML Document.) Prohibited Actions include: Run, ExecuteAddOn, FileCopy, FileDelLine, FileErase, FileInsLine, FileRead, FileWrite, SendKeys, SaveVariables, CreateFolder, RemoveFolder, RegistryRead, RegistryWrite, SendMail, ExtractFile, Suspend, RunVisualNEO Win, ClickMouse and all plug-in based Actions. Disable the Enhanced Security option if you wish to allow the above Actions to be executed. However, if this Web Browser object will have unrestricted access to the Internet, it is highly recommended that you leave the Enhanced Security option enabled.


Actions

The Web Browser supports the following Action Events: Before Navigate, Download Begin, Download Complete and Navigate Complete. Click the appropriate tab at the bottom of the Action Editor to create or edit Actions for the events you want to control. See Understanding Actions and Variables and Action Command Reference for a complete discussion of the Action Editor and Action Commands.


The Before Navigate Action can be used to prevent readers from leaving the current web site or viewing sites that you do not want them to see. At runtime, you can prevent or redirect navigation by changing the contents of the variable containing the current URL address from within the Before Navigate Action. For example, the following code placed in the Before Navigate Action will prevent the Browser from displaying any pages that are not part of Microsoft’s web site:


SearchStr "microsoft.com" "[WebBrowser1Addr]" "[Found]"

If "[Found]" "=" "0"

  SetVar "[WebBrowser1Addr]" ""

  AlertBox "Sorry" "That’s not an authorized web address."

EndIf


The Before Navigate Action could also be used to keep a log of which web sites were visited. For example:

FileWrite "activity.log" "Append" "[Time]: [WebBrowser1Addr]"


The [Time] variable above adds the current time to the activity.log file along with the address of the site visited.


The Download Begin and Download Complete Actions are triggered whenever the Browser downloads content over the Internet. These Actions can be used to display a message or play an animation indicating to the reader that the computer is busy.


The Navigate Complete Action is executed when the entire HTML document or web page and all of its elements (images, links, etc.) have finished downloading.


Embedding VisualNEO Win Actions Inside an HTML Document

Special hyperlinks can be added to HTML documents to execute VisualNEO Win Action commands. If you're using an HTML editor, such as Microsoft's FrontPage®, you can enter VisualNEO Win Actions instead of a traditional URL address when creating hyperlinks. Just precede the command with "VisualNEO Win:". For example:


neobook:GotoPage "Main"


Adding "VisualNEO Win:" to the beginning of the hyperlink tells the Web Browser that VisualNEO Win should process the command instead of Internet Explorer. This only works when the HTML document is displayed inside VisualNEO Win's Web Browser object. Stand-alone browsers like Internet Explorer, Chrome or FireFox cannot execute VisualNEO Win Actions.


If you prefer to edit your HTML documents manually, the code for a VisualNEO Win hyperlink would look like this:


Click this <a href="neobook:GotoPage %22Main%22">link</a> to jump to another VisualNEO Win page.


Notice the special codes (%22) where you would expect to see quotation marks surrounding the action's parameter. Since quotation marks have special meaning in HTML, we can't use them here. Instead we place %22 wherever we would normally place a quotation mark. This is not necessary when using an HTML editor, as the editor will replace any special characters automatically.


If you want to add more than one Action to a hyperlink, you can separate them with another special code - %0D (%+zero+D). This is the hexadecimal code for a carriage return. For example:


Click this <a href="neobook:AlertBox %22Hello%22 %22About to switch pages.%22%0DGotoPage %22Main%22">link</a> to jump to another VisualNEO Win page.


If your HTML editor doesn't allow you to enter the %0D code, you can use the character (ASCII #0182) instead. For example:


Click this <a href="neobook:AlertBox %22Hello%22 %22About to switch pages.%22¶GotoPage %22Main%22">link</a> to jump to another VisualNEO Win page.


In addition to the default “neobook:” prefix, you may optionally use the publication’s title instead. However, if your title includes spaces, they must be removed. For example, if your publication’s title is “My Super Cool Program”, then the hyperlink should look like this:


mysupercoolprogram:GotoPage "Main"


For security reasons, an Action that could be potentially dangerous, such as FileWrite, FileErase, etc. cannot be executed from the Web Browser object unless the Enhanced Security option above is disabled.


Note: VisualNEO Win's compiler will not detect external files used by Actions embedded inside HTML documents. If you use VisualNEO Win Actions here that reference text or media files, you will need to link those files elsewhere in your publication or make other arrangements to insure that all needed files are distributed with your compiled exe.


Passing Information Between the Browser and VisualNEO Win


The Web Browser object includes support for three special external methods that can be used by JScript or VBScript programmers to interact with VisualNEO Win. These external methods (called nbGetVar, nbSetVar and nbExecAction) can be combined with VisualNEO Win's BrowserGetElement, BrowserSetElement and BrowserExecScript actions to establish two-way communication between the Web Browser's content and your publication. This provides VisualNEO Win publications with direct access to many powerful JavaScript and VBScript features. With these tools, you can essentially use JScript/VBScript to augment VisualNEO Win's own scripting language.


Note: Some experience with HTML and JScript or VBScript are required to use these features.


External methods supported by VisualNEO Win's Web Browser object:


nbSetVar

Purpose:

This method assigns a string value to a VisualNEO Win variable.

Syntax:

window.external.nbSetVar( variable name, value )

variable name

The name of a VisualNEO Win variable. The variable name should be surrounded by square brackets.

value

The value to assign to the variable. Must be of type string.

Example:

The following HTML JScript copies the contents of two Text Boxes called "FirstName" and "LastName" to the VisualNEO Win variables [FirstName] and [LastName]:


<script language="JScript">

function SetVars() {

  window.external.nbSetVar( '[FirstName]', mainform.FirstName.value );

  window.external.nbSetVar( '[LastName]', mainform.LastName.value );

  }

</script>


nbGetVar

Purpose:

This method returns a string containing the contents of a VisualNEO Win variable.

Syntax:

value = window.external.nbGetVar( variable name )

variable name

The name of the VisualNEO Win variable to retrieve. The variable name should be surrounded by square brackets.

value

The contents of the VisualNEO Win variable in string format.

Example:

The following HTML JScript copies the contents of VisualNEO Win's [FirstName] and [LastName] variables to two Text Boxes called "FirstName" and "LastName":


<script language="JScript">

function GetVars() {

  mainform.FirstName.value = window.external.nbGetVar( '[FirstName]' );

  mainform.LastName.value = window.external.nbGetVar( '[LastName]' );

  }

</script>


nbExecAction

Purpose:

Use this method to execute VisualNEO Win actions.

Syntax:

window.external.nbExecAction( action script )

action script

The VisualNEO Win action to execute. Multiple actions may specified by separating them with a carriage return.

Example:

This example executes VisualNEO Win's AlertBox action:


<script language="JScript">

function DoExec() {

  window.external.nbExecAction( 'AlertBox "Hello" "Hello from the Web Browser!"' );

}

</script>


Note: These features require the user's Internet Security/Active Scripting option to be enabled.