Support Article
Script function in HTML is invoked when 'ENTER' Key is pressed
SA-2425
Summary
Developer has built a section that references a HTML fragment. The HTML fragment has markup which displays 2 icons on the UI screen
and a JavaScript function X to be invoked when the icons are clicked. When user navigates to the portion of the screen that displays these icons and presses 'ENTER' key, the javascript function configured on the 'ONCLICK' of the icons gets triggered.
Error Messages
None
Steps to Reproduce
Build a section that references a HTML fragment. Put HTML markup which displays 2 icons on the UI screen and a JavaScript function X to be invoked when the icons are clicked. At runtime, navigate to the portion of the screen that displays these icons and presses 'ENTER' key.
Resolution
The issue can be resolved by doing the below:
a) Create a new JS file rule and copy the script function from HTML fragment rule into this JS file.
b) Include the JS file under 'Scripts and Styles' tab of the harness.
c) Configure the section to include an icon instead of the HTML fragment rule and configure ONCLICK of the icon to 'Run a Script' function.
Published January 31, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.