Gen Web View HTML Control custom button does not work
search cancel

Gen Web View HTML Control custom button does not work


Article ID: 210067


Updated On:


Gen - Workstation Toolset Gen


An HTML Control custom button is coded with same ID as the html code generated for a Gen Window designed "ok" button. The custom button executes the Gen "ok" button function successfully in Web Generation but does nothing in Web View.


Release : 8.6


Web View is different to Web Generation because an iframe is used for each custom HTML Control to separate it from the main Gen page and other HTML Controls to avoid any unexpected conflicts.
Due to the use of iframes the custom HTML Control defined button is not aware of the Gen button and it needs to "Traverse the DOM" 
The following example shows how a custom HTML Control containing a button "TestOK" uses a clickFunction() to enable it to execute the Gen button "ok".
Note: It was found that due to dynamic changes to the button ID the ID itself could not be used so instead of using "getElementById" the approach is to use "getElementsByTagName".

<button id="gen-Button1" name="Button1" class="Button1 gen_button regbutton" type="button" onclick="clickFunction()" >TestOK</button>
function clickFunction() {
         // Search for element/button in DOM and click 
         // get the button elements from the doc we want
         var genbuttons = parent.document.getElementsByTagName('button');
         // iterate to find which one of the buttons we want to use
         for ( x= 0; x < genbuttons.length; x++ ) { // we want Gen button to click for the one whose label/text is "ok"
             if ("ok" == genbuttons[x].innerText) {
                  // this is the button we needed.