0

I want to make an iframe in which i load a web page that i have on other server and i would like to fill some inputs via jquery, i know i cant do this since both apps are on different servers and have different ips, but i tried the next thing.

I made an URL rewrite on my IIS so my Host app matches 192.168.25.17 and made an url for the child app match the next ip 192.168.25.17/mysecondapp so i tried to run a jquery and it failed, so i checked the document.domain and both says its 192.168.25.17 what am doing wrong? or how can i check what is troubling me for working around the policy?

    <button class="btn btn-success" id="botondeMagia">Set UserName</button>        
    <div id="magicContainer">
                <iframe id="foo" src="http://192.168.25.17/apex/anapp.faces" height="500px">
                </iframe>
    </div>

     <script>
    $("#botondeMagia").on('click', function() {
    $("#magicContainer input").val("TEST!!");
    $("#magicContainer input").text("TEST!!");

});</script>

I don't know if the next info is useful but, the second app doesnt have jquery, just the hosting app.

The guest app is hosted in tomcat

Thank you very much

Edwin Zelaya
  • 31
  • 1
  • 4
  • We can't tell why JavaScript you haven't shared with us behaves in the unexpected way you haven't described. Since you say that two URLs now have the same origin, it won't be the same origin policy getting in the way. – Quentin Jan 18 '16 at 15:18
  • Do you control both domains and can put code into both pages? If so there are several ways you can set up iframe-parent scripts. – charlietfl Jan 18 '16 at 15:23
  • Duplicate: http://stackoverflow.com/questions/1796619/how-to-access-the-content-of-an-iframe-with-jquery (pay attention to the accepted answer, some of the others assume cross-origin problems which you don't have to worry about). – Quentin Jan 18 '16 at 15:29

1 Answers1

0

Actually Quentin is right, i had to use

          $("#magicContainer").contents() 

for viewing the contents on it, URL rewrite actually is great workaround for this tho

thank you so much guys

Edwin Zelaya
  • 31
  • 1
  • 4