Hey, I'm trying to get JS to simulate a link click in an iframe on my page. Normally I would just change the src of the iframe, but the link I need to click contains a code that is different each time, and will not work with a different (or no) code.
I have this:
HTML Code:
<iframe width='600' height='400' id='iframe' name='iframe' src='page.php'></iframe>
and my JS thus far is this:
Code:
document.getElementById('iframe').links[25].click();
However, that gives the error:
I have tried using document.iframe.links... as well but get a similar result.
Does anyone know where I'm going wrong or have a better way to 'click' that link? Manually clicking the link is out of the question, as this script will be run many times in succession and I don't want to stay up all night
.
I've also tried using the following.
Code:
frames['iframe'].document.links[25].click();
However, that gives the error: "Permission denied to get property Window.document".
EDIT: I now realise that I cannot do this due to the iframe containing a site from a different domain to my own. This is an entirely different problem