I am working on an iOS app that performs some actions in a webview using injected javascript. I am trying to press a submit button on a router's web-interface (So I can't give you a url). I've tried many other proposed solutions online but nothing is working. One thing I must do is click an input button of type=SUBMIT and for whatever reason it is not responding. I have tried using .click() along with calling the onClick event handler, but nothing is working. Any help is appreciated. The HTML code is below:
<div class="fix_button">
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tbody>
<tr>
<td nowrap="" colspan="2" align="center">
<input class="cancel_bt" type="RESET" name="Cancel" value="Cancel" onclick="doCancel();" languagecode="51">
<input class="apply_bt" type="SUBMIT" name="Apply" value="Apply" onclick="return checkData();" languagecode="50">
</td>
</tr>
</tbody>
</table>
</div>
The input button is the one with the class="apply_bt"
. This div is within an iframe and submits data that is within another iframe within this frame. The structure is sort of like this:
<iframe>
// Contains the Apply Button
<div class="fix_button"></div>
// Contains the iframe where the info to be submitted is
<div id="main" class="main_top_button">
// Contains data to be submitted
<iframe src="WLG_2g_wireless2.htm&todo=wifi_primary_init" id="2g_setting" name="wl2gsetting" onload="SetCwinHeight(this.id)" marginheight="0" marginwidth="0" scrolling="no" width="100%" frameborder="0" height="288px">
</iframe>
</div>
</iframe>
This is the code I am using to click the button:
// Gets the outer iframe
iframe1 = document.getElementById("formframe");
// Gets the html within the iframe
var innerDoc=iframe1.contentDocument || iframe1.contentWindow.document;
// Gets iframe within the iframe
innerframe = innerDoc.getElementById("2g_setting");
// Gets the html within the inner iframe
var innerDoc2=innerframe.contentDocument || innerframe.contentWindow.document;
// I Enter some data in the inner iframe (not shown), this portion
// of the code works perfectly. I can see fields being entered and
// buttons being clicked.
// Then I click the apply button...
innerDoc.getElementsByName("Apply")[0].click()
// And nothing happens
I am able to get the element and read data from the Apply Button, such as its text, but I am not able to perform a .click() action on the button. Also, I am not getting any errors. I have no idea why its not working. Please help!