Where do I store Javascript in my answerSpace?
Sometimes an interaction may require some additional javascript. It maybe part of a form, a object or element function, or just an alert message. Javascript can be stored in several places.
Where can I insert Javascript?
- Within the interaction itself.
- Within another answerspace called by the Blink run API
- From an external source.
- Within a BlinkForms Object
- Within the HTML Head of your Answerspace
$html = "<script> alert('This Is A Javascript Alert'); "; echo $html;
Using $t->runInteraction()
Within another answerspace called by the Blink run API. This function calls javascript from an internal source stored in an interaction "photoswipe-3.0.4.js. It is using the Blink API run interaction. The reference to the interaction containing the javascript is stored in setupanswerSpace->load external javascript and is available when the answerspace is loaded.
From an external source.
The reference to the external source file containing the javascript is stored in the answerspace setup->load external javascript and is available when the answerspace is loaded. While this method is available it is not recommended as it may extend the loading time of the answerspace if the external source has a limited bandwidth.
Additionally a native application version of the answerspace will require the external source domain to be white-listed as it breaks outside the answerspace domain. This may cause a Child Browser Window to load with blank content when the javascript function is called.
Within a BlinkForm Object.
here are a number of areas Javascript code can be placed within the BlinkForms builder. Anywhere you can HTML tags, you can add Javascript, as long as it is wrapped in a script tag.
- Step 4 Header and Footer
- Custom Code area
Within the HTML Head of your Answerspace
Javascript here will be available to the entire answerSpace.
Related articles