1

Hi included a site with iframe into my site which contains XML informations and I want to get the Value of a Element from the Iframe through get ElementsByTagName but Im struggling with it.

Problem is I need to send an XML Request to the server to get the response and the response Im displaying in an Iframe now i need somehow to get the response out of the iframe.

document.getElementById("myiframeexample").onload = function () {
 var submissionid = document.getElementById("myxmlframe").contentWindow.document.getElementsByName("testdata")[0].value;
 document.getElementById("testline").innerHTML = submissionid; 
          
<body id="myiframeexample">
<div class="iframebox" style="display:none;">
  <iframe id="myxmlframe" src="https://test.de/Auth/"></iframe>
  <div class="">
    <form action="verify.php" method="post">
      <div class="inputbox">
        <p class="testline"></p>
      </div>
      <input type="submit" value="submit">
     </form>
     </div>
   
  

The xml file inside the iframe looks as followed:

<?xml version="1.0" encoding="UTF-8"?><data><testdata>100</testdata></data>
Dan Smails
  • 21
  • 3
  • Possible duplicate of [using document.getElementsByTagName on a page with iFrames - elements inside the iframe are not being picked up](https://stackoverflow.com/questions/11144479/using-document-getelementsbytagname-on-a-page-with-iframes-elements-inside-the) – Alex Jun 14 '18 at 15:19
  • Possible duplicate of [jQuery/JavaScript: accessing contents of an iframe](https://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe) – Fuzzyma Jun 14 '18 at 17:05
  • Any specific reason for using this “poor man’s AJAX” construct …? – CBroe Jun 15 '18 at 10:19
  • @CBroe yeah I tried it already with ajax XMLHttpRequest but it didnt work. So I tried it now with this solution and at least with this solution Im getting the response. Cause in the iframe is the response of the server regarding the request I was sending to the server through post. If you could help me with ajax I can post my ajax query and you could also check it why it wont work. – Dan Smails Jun 15 '18 at 16:25

0 Answers0