Conduit API
Case Study
HTML Apps -> JSInjection
 
This function is used to inject JavaScript into the web page currently displayed in the browser in the active tab (app-to-webpage only). It enables the publisher to add logic and modify the structure of a currently-visited web page. Note that changes to the page take place on the client side and are not permanent.
 
JSInjection(strScript)
 
Parameter Description Range Type
strScript JavaScript commands to be executed on the web page currently loaded in the browser's active tab. Any JavaScript code string
 
  • Boolean (Succeeded or not)
  • Function "EBCallBackMessageReceived(data)" is called after the injection is completed. (Optional) The parameter can be used to pass a value to the function during execution of the injected code.
 
  • The injected JavaScript code can include one or more lines and can also include the callback function "EBCallBackMessageRecieved(data)" that will be executed after the injection is completed.
  • Calling other user-defined functions from within the injected code is possible only if they are also implemented inside the injected code.
  • This function requires special permissions. You will need to apply the following security settings to your app.
  • This function can be used both with the HTML app and with the gadget window.
*Notice: API methods must be invoked after the web page has triggered the "onload" event.
 
This example contains four buttons with different colors. Clicking on one of the buttons will change the background color of the current web page to the specified color. When color change is done, a ‘success’ message will be displayed (using the callback function).
JSInjection