Applies to
Ion 3.0 and above
Summary
Browsium Ion 3 removed the “Script Injection” feature. Script Injection wrapped arbitrary JavaScript in <script> tags and inserted them into an html page. To inject JavaScript with Browsium Ion 3 and later, use String Replacement.
Details
How to Inject JavaScript into an HTML Resource
- Assume you wish to inject a script into the html resource “http://my.app.com/index.html.”
- Navigate to the html resource in Internet Explorer.
- Right click on the page and select “View source.”
- Locate the <head> tag.
- Find a unique target string within the <head> tag. This string tells Browsium Ion where to inject your JavaScript. WARNING: If it the target string is not unique, Ion will inject the script multiple times.
- Using Browsium Ion Configuration Manager, open your Project.
- Open the “Profiles” node in the “Objects” panel on the left.
- Click on the Profile that is applied to the html resource.
- Click “String Replacement Manager” and select “Add String Replacement…” from the “Actions” pane.
- Type the html resource URI in the “Target URI” field, e.g. “http://my.app.com/index.html.”
- Type the unique string from #5 in the “String to Find” field. E.g., enter “<link type=’text/css’ rel=’stylesheet’ href=’css/core.css’/>.”
- In the “Replace with” field, re-enter the string from #5 followed by “<script type=’text/javascript’>.”
- Add your script followed by a closing </script> tag. Your entry will look like this:
<link type=’text/css’ rel=’stylesheet’ href=’css/core.css’/>
<script type=’text/javascript’>
alert(‘Hello!’);
</script>
- Click OK.
- Save the Project to Local Settings. When you navigate to the html resource, Browsium Ion will inject the script into the page.
Posted in: Ion Knowledge Base,