Advanced DomInjection Sample for Enterprise Browser on Android

Sabir Valappil Thattath -

DomInjection is one of the cool features of Enterprise Browser used by many enterprise customers. It helps user to have customized behavior at the device side without modifying the server application. DomInjection in Enterprise Browser 2.0 has undergone few enhancements which makes dominjection easier.

Earlier version of the dominjection were having some concerns related to providing absolute path to the injected files on the device. Absolute path to installed directory on the android devices were not common which was creating issues to customers when 'tags' file were mass deployed. This resulted in maintaining multiple 'tags' files for different set of devices. Another concern was related to injecting scripts; to specific pages. When pages='*' attribute was used in 'tags' file, scripts were getting injected to all navigated pages. This resulted in writing additional logic in the injected script to ensure changes are only applied to the specific pages.

Enterprise Browser 2.0 allows user to provide dominjected files path using substitution variables that allows user to forget the difficulty involved in finding the absolute path to installed directory and maintaining multiple 'tags' files. It also introduced additional attribute named 'pagecontent' inside 'tags' file; where user can provide unique string to identify the page on which dominjection needs to applied.

This blog provides insight to the dominjection enhancements gone into Enterprise Browser 2.0 with the help of a sample application on a TC51/TC56 device.

What Application Covers?

Application has a start page which resides locally on the device.Startpage has 3 href links which takes user to Google, Yahoo and Example domain respectively. Assume the start page is a legacy page which was migrated from Windows devices to Android touch devices where we do not have any F2, F3, F4,F5 hardware keys on the device. We are going to insert on-screen-buttons for F2,F3, F4 ,F5 for the startpage dynamically using dominjection method. However we need these buttons (F2, F3, F4, F5) only on the legacy page (in our case startpage)

Google and Yahoo in our case are two pages where customer wants to insert some custom buttons to perform some javascript actions. These buttons are common for both Google and Yahoo, however javascript actions are different on both pages. We insert F6, F7,F8,F9 on-screen-buttons dynamically for pages Google and Yahoo in our sample application. On clicking the button, we will execute the corresponding javascript action associated with each page. We have a special requirement here that on-screen-button should not create any page content visibility issues. We will resize the webview only for Google and Yahoo using dominjection.

Example Domain is a page where we have a requirement to insert an HTML button with some javascript action. In our case, we inject a button to enable or disable the battery indicator on the screen.

We are now ready with multiple requirements for different pages. Let us see how we are going to enable the same using dominjection with the help of Enterprise Browser 2.0

Addressing the requirement for Startpage!

In our example, startpage has a logic already existing from windows time to change the background color when function keys are pressed. Let us see, how we are going to create on-screen-buttons F2, F3,F4, F5 for the startpge without modifying the application. To have a on-screen-button that simulates a keydown event, one need to use buttonbar feature of Enterprise Browser. The sample includes a button.xml used in our case. ButtonBar xml has a grammar that defines the required button and action along with other button properties such as color, size etc.

To know more about buttonbar, please visit

A snapshot from our example is placed here
















Once the button.xml is created, one can use buttonBar API to show or hide the created-button-bar in any page. As the buttonbar gets created on Enterprise Browser Launch, we only need to inject a script to show the buttonBar1 whenever startpage is loaded. Similarly we have to hide the buttonBar1 when we moved out of the page.

Inspect the 'tags' file used for startpage DomInjection!


Sabir Valappil Thattath

Please register or login to post a reply