I was reading this question, but my script is still not working: Can javascript running inside an iframe affect the main page?
I have my main page test.php
<div id="testfield">Some text here</div>
<iframe id="upload_target" name="upload_target" src="" style="..."></iframe>
In the iframe page I have a button that should be removing what's inside a div on the main page.
<button onclick="goNow();">TEST ME</button>
And this is the Javascript part that is triggered when pressed the button:
function goNow() {
parent.getElementById('testfield').innerHTML = '';
}
This all works on one page with document.getElementById, but once I use the iframe and parent.getElementById it returns an error:
Error: Object doesn't support property or method 'getElementById'