0

I need to pass a value from parent to iframe using javascript but both are in different domain.

i tried using the below but still i am unable to achieve this, after passing the text i need to send enter key to go to the next page

<!DOCTYPE html>
<html>
<body>
<iframe id="myFrame" src="https://sitechecker.pro/iframe-test/" style="height:380px;width:100%"></iframe>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
  var iframe = document.getElementById("myFrame");
  var elmnt = iframe.contentWindow.document.getElementsById("minitool_input")[0];
  elmnt.innerHTML = "http://google.com";
}
</script>

</body>
</html>
Fshbet
  • 5
  • 5
  • Can you please clarify the question? Do you want to change the `src` of `iframe` after clicking on the button? – Dibas Dauliya Nov 08 '21 at 07:05
  • No i need to input the "google.com" inside the text box which is available in the iframe "https://sitechecker.pro/iframe-test/" – Fshbet Nov 08 '21 at 07:07
  • does this answer your question? https://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame – ProDec Nov 08 '21 at 07:09
  • sample image https://ibb.co/Xs1VCmY – Fshbet Nov 08 '21 at 07:11
  • @ProGu sorry i think it is too advanced, if you can please update the above script to work as i am a noobs in js – Fshbet Nov 08 '21 at 07:17

0 Answers0