Knowledge Base

Script Injection with Ion

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

  1. Assume you wish to inject a script into the html resource “http://my.app.com/index.html.”
  2. Navigate to the html resource in Internet Explorer.
  3. Right click on the page and select “View source.”
  4. Locate the <head> tag.
  5. 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.
  6. Using Browsium Ion Configuration Manager, open your Project.
  7. Open the “Profiles” node in the “Objects” panel on the left.
  8. Click on the Profile that is applied to the html resource.
  9. Click “String Replacement Manager” and select “Add String Replacement…” from the “Actions” pane.
  10. Type the html resource URI in the “Target URI” field, e.g. “http://my.app.com/index.html.”
  11. 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’/>.”
  12. In the “Replace with” field, re-enter the string from #5 followed by “<script type=’text/javascript’>.”
  13. 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>
    script-injection
  14. Click OK.
  15. 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,

  • Share:  

Request Demo

Internet Explorer End of Life problems?Learn More