3 Replies - 5601 Views - Last Post: 09 February 2011 - 08:09 AM

#1 Arkwind  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 28-November 08

Click A Button Within An Iframe

Posted 07 February 2011 - 12:25 PM

Hi There.

I am working on a PM system for a website of mine, I want to load a webpage that contains a draft email inside an iframe, and have javascript code outside of the iframe that clicks the Submit button within the iframe.

I know this is possible but code such as:

onmouseover="window.frames[0].document.getElementById('submit').click()";



doesn't work.

Thanks for your time, any input will be well received.

This post has been edited by Arkwind: 07 February 2011 - 12:26 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Click A Button Within An Iframe

#2 forest51690  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 58
  • View blog
  • Posts: 340
  • Joined: 20-March 09

Re: Click A Button Within An Iframe

Posted 07 February 2011 - 12:49 PM

I think you have to access the iFrame's document like so:
window.frames[0].contentwindow.document

Was This Post Helpful? 0
  • +
  • -

#3 Arkwind  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 28-November 08

Re: Click A Button Within An Iframe

Posted 07 February 2011 - 01:29 PM

Thanks for the response - but its still not working - here is what I have tried:

window.frames[framename].document.getElementById('submit').click();  - doesn't work



window.frames[framename].contentwindow.document.getElementById('submit').click(); - doesn't work



window.frames[0].contentwindow.document.getElementById('submit').click(); -doesn't work



window.frames[0].document.getElementById('submit').click(); -doesn't work



If it helps im using the javascript like this:

<input type="button" onclick="window.frames[0].document.getElementById('submit').click();">


Thanks

This post has been edited by Arkwind: 07 February 2011 - 01:30 PM

Was This Post Helpful? 0
  • +
  • -

#4 init.d.httpd  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 30
  • View blog
  • Posts: 132
  • Joined: 02-February 11

Re: Click A Button Within An Iframe

Posted 09 February 2011 - 08:09 AM

Is the id submit a link or a input type="submit" ?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1