Clicking a button on an iframe

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • quizwedge
    New Member
    • Oct 2006
    • 5

    Clicking a button on an iframe

    I've got an ASPX page with an iframe that has another ASPX page. When the "Next" button is clicked on the main page, I want it to click the "Save" html input button on the iframe page. On the back end of the main page, I have the following line:

    btnNext.Attribu tes.Add("onClic k", "window.fra mes[0].document.getEl ementById('btnS ave').click();" )

    This works fine in IE. It also works fine in FireFox if I add a window.alert after the click. Without the window.alert, it doesn't work in FireFox. What am I missing?
  • quizwedge
    New Member
    • Oct 2006
    • 5

    #2
    Follow up on this: It appears that it is running the code on the main page first, instead of the clicked button on the iframe. The main page has code on the backend to verify that the work in the iframe has been done first. It seems that IE is running the iframe first, but FireFox does not. How do I make FireFox handle it like IE does?

    Comment

    • quizwedge
      New Member
      • Oct 2006
      • 5

      #3
      Well, it appears that IE will process a javascript click of a button on an iframe and then code running on the main page whereas Firefox does the opposite. To fix this, I did the following code:


      window.frames[0].document.getEl ementById('btnS ave').click(); setTimeout('doc ument.getElemen tById(\'ctl00_C ontentPlaceHold er1_btnMainSave \').click()', 250);

      This forces Firefox to wait on the main document code, giving it time to run the iframe code. Hopefully, if this affects anyone else, they'll find this post.

      Comment

      Working...